• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java LintClient类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.android.tools.lint.client.api.LintClient的典型用法代码示例。如果您正苦于以下问题:Java LintClient类的具体用法?Java LintClient怎么用?Java LintClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

LintClient类属于com.android.tools.lint.client.api包,在下文中一共展示了LintClient类的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createCache

点赞 3

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private static boolean createCache(LintClient client, File xmlFile, File binaryData, boolean isSupport) {
    long begin = 0;
    if (WRITE_STATS) {
        begin = System.currentTimeMillis();
    }

    Api info = Api.parseApi(xmlFile);

    if (WRITE_STATS) {
        long end = System.currentTimeMillis();
        System.out.println("Reading XML data structures took " + (end - begin) + " ms)");
    }

    if (info != null) {
        try {
            writeDatabase(binaryData, info, isSupport);
            return true;
        } catch (IOException ioe) {
            client.log(ioe, "Can't write API cache file");
        }
    }

    return false;
}
 

开发者ID:evant,
项目名称:silent-support,
代码行数:25,
代码来源:ApiLookup.java

示例2: getPlatformVersion

点赞 3

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
@VisibleForTesting
@Nullable
static String getPlatformVersion(@NonNull LintClient client) {
    LocalSdk sdk = client.getSdk();
    if (sdk != null) {
        LocalPkgInfo pkgInfo = sdk.getPkgInfo(PkgType.PKG_PLATFORM_TOOLS);
        if (pkgInfo != null) {
            FullRevision version = pkgInfo.getDesc().getFullRevision();
            if (version != null) {
                return version.toShortString();
            }
        }
    }

    return null;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:17,
代码来源:ApiLookup.java

示例3: createCache

点赞 3

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private static boolean createCache(LintClient client, File xmlFile, File binaryData) {
    long begin = 0;
    if (WRITE_STATS) {
        begin = System.currentTimeMillis();
    }

    Api info = Api.parseApi(xmlFile);

    if (WRITE_STATS) {
        long end = System.currentTimeMillis();
        System.out.println("Reading XML data structures took " + (end - begin) + " ms)");
    }

    if (info != null) {
        try {
            writeDatabase(binaryData, info);
            return true;
        } catch (IOException ioe) {
            client.log(ioe, "Can't write API cache file");
        }
    }

    return false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:25,
代码来源:ApiLookup.java

示例4: replaceUrlWithValue

点赞 3

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private static String replaceUrlWithValue(@NonNull XmlContext context,
        @NonNull String str) {
    Project project = context.getProject();
    LintClient client = context.getClient();
    if (!client.supportsProjectResources()) {
        return str;
    }
    ResourceUrl style = ResourceUrl.parse(str);
    if (style == null || style.type != ResourceType.STRING || style.framework) {
        return str;
    }
    AbstractResourceRepository resources = client.getProjectResources(project, true);
    if (resources == null) {
        return str;
    }
    List<ResourceItem> items = resources.getResourceItem(ResourceType.STRING, style.name);
    if (items == null || items.isEmpty()) {
        return str;
    }
    ResourceValue resourceValue = items.get(0).getResourceValue(false);
    if (resourceValue == null) {
        return str;
    }
    return resourceValue.getValue() == null ? str : resourceValue.getValue();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:26,
代码来源:AppIndexingApiDetector.java

示例5: testLineEndings

点赞 3

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
public void testLineEndings() throws Exception {
    // Test for http://code.google.com/p/android/issues/detail?id=22925
    String xml =
            "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
            "<LinearLayout>\r\n" +
            "\r" +
            "<LinearLayout></LinearLayout>\r\n" +
            "</LinearLayout>\r\n";
    LintCliXmlParser parser = new LintCliXmlParser();
    File file = File.createTempFile("parsertest2", ".xml");
    //noinspection IOResourceOpenedButNotSafelyClosed
    Writer fw = new BufferedWriter(new FileWriter(file));
    fw.write(xml);
    fw.close();
    LintClient client = new TestClient();
    LintDriver driver = new LintDriver(new BuiltinIssueRegistry(), client);
    Project project = Project.create(client, file.getParentFile(), file.getParentFile());
    XmlContext context = new XmlContext(driver, project, null, file, null, parser);
    Document document = parser.parseXml(context);
    assertNotNull(document);

    //noinspection ResultOfMethodCallIgnored
    file.delete();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:25,
代码来源:LintCliXmlParserTest.java

示例6: getPlatformVersion

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
@VisibleForTesting
@Nullable
static String getPlatformVersion(@NonNull LintClient client) {
    AndroidSdkHandler sdk = client.getSdk();
    if (sdk != null) {
        LocalPackage pkgInfo = sdk
                .getLocalPackage(SdkConstants.FD_PLATFORM_TOOLS, client.getRepositoryLogger());
        if (pkgInfo != null) {
            return pkgInfo.getVersion().toShortString();
        }
    }
    return null;
}
 

开发者ID:evant,
项目名称:silent-support,
代码行数:14,
代码来源:ApiLookup.java

示例7: create

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/**
 * Returns an instance of the API database
 *
 * @param client  the client to associate with this database - used only for
 *                logging
 * @param xmlFile the XML file containing configuration data to use for this
 *                database
 * @return a (possibly shared) instance of the API database, or null
 * if its data can't be found
 */
public static ApiLookup create(LintClient client, File xmlFile, boolean isSupport) {
    if (!xmlFile.exists()) {
        client.log(null, "The API database file %1$s does not exist", xmlFile);
        return null;
    }

    File cacheDir = client.getCacheDir(true/*create*/);
    if (cacheDir == null) {
        cacheDir = xmlFile.getParentFile();
    }

    String platformVersion = getPlatformVersion(client);
    File binaryData = new File(cacheDir, getCacheFileName(xmlFile.getName(), platformVersion));

    if (DEBUG_FORCE_REGENERATE_BINARY) {
        System.err.println("\nTemporarily regenerating binary data unconditionally \nfrom "
                + xmlFile + "\nto " + binaryData);
        if (!createCache(client, xmlFile, binaryData, isSupport)) {
            return null;
        }
    } else if (!binaryData.exists() || binaryData.lastModified() < xmlFile.lastModified()
            || binaryData.length() == 0) {
        if (!createCache(client, xmlFile, binaryData, isSupport)) {
            return null;
        }
    }

    if (!binaryData.exists()) {
        client.log(null, "The API database file %1$s does not exist", binaryData);
        return null;
    }

    return new ApiLookup(client, xmlFile, binaryData, null, isSupport);
}
 

开发者ID:evant,
项目名称:silent-support,
代码行数:45,
代码来源:ApiLookup.java

示例8: ApiLookup

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private ApiLookup(
        @NonNull LintClient client,
        @NonNull File xmlFile,
        @Nullable File binaryFile,
        @Nullable Api info,
        boolean isSupport) {
    mInfo = info;
    mIsSupport = isSupport;

    if (binaryFile != null) {
        readData(client, xmlFile, binaryFile);
    }
}
 

开发者ID:evant,
项目名称:silent-support,
代码行数:14,
代码来源:ApiLookup.java

示例9: getConfiguration

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/**
 * Gets the configuration for the test.
 * Each test can have a set of enabled issues by assigning the member field {@link #mEnabled}.
 */
@Override
protected TestConfiguration getConfiguration(LintClient client, Project project) {
    return new TestConfiguration(client, project, null) {
        @Override
        public boolean isEnabled(@NonNull Issue issue) {
            return super.isEnabled(issue) && mEnabled.contains(issue);
        }
    };
}
 

开发者ID:cch-robo,
项目名称:Android_Lint_SRP_Practice_Example,
代码行数:14,
代码来源:SharingGroupClassificationDetectorTest.java

示例10: getConfiguration

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
@Override
protected TestConfiguration getConfiguration(LintClient client, Project project) {
    return new TestConfiguration(client, project, null) {
        @Override
        public boolean isEnabled(@NonNull Issue issue) {
            return super.isEnabled(issue) && mEnabled.contains(issue);
        }
    };
}
 

开发者ID:inaka,
项目名称:lewis,
代码行数:10,
代码来源:IconInLibraryTest.java

示例11: Project

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/** Creates a new Project. Use one of the factory methods to create. */
protected Project(
        @NonNull LintClient client,
        @NonNull File dir,
        @NonNull File referenceDir) {
    mClient = client;
    mDir = dir;
    mReferenceDir = referenceDir;
    initialize();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:11,
代码来源:Project.java

示例12: getEncodedString

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/**
 * Returns the encoded String for the given file. This is usually the
 * same as {@code Files.toString(file, Charsets.UTF8}, but if there's a UTF byte order mark
 * (for UTF8, UTF_16 or UTF_16LE), use that instead.
 *
 * @param client the client to use for I/O operations
 * @param file the file to read from
 * @return the string
 * @throws IOException if the file cannot be read properly
 */
@NonNull
public static String getEncodedString(
        @NonNull LintClient client,
        @NonNull File file) throws IOException {
    byte[] bytes = client.readBytes(file);
    if (endsWith(file.getName(), DOT_XML)) {
        return PositionXmlParser.getXmlString(bytes);
    }

    return getEncodedString(bytes);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:22,
代码来源:LintUtils.java

示例13: TestConfiguration

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
public TestConfiguration(
        @NonNull LintClient client,
        @Nullable Project project,
        @Nullable Configuration parent,
        @NonNull File configFile) {
    super(client, project, parent, configFile);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:8,
代码来源:LintDetectorTest.java

示例14: get

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/**
 * Returns an instance of the API database
 *
 * @param client the client to associate with this database - used only for
 *            logging. The database object may be shared among repeated invocations,
 *            and in that case client used will be the one originally passed in.
 *            In other words, this parameter may be ignored if the client created
 *            is not new.
 * @return a (possibly shared) instance of the API database, or null
 *         if its data can't be found
 */
@Nullable
public static ApiLookup get(@NonNull LintClient client) {
    synchronized (ApiLookup.class) {
        ApiLookup db = sInstance.get();
        if (db == null) {
            File file = client.findResource(XML_FILE_PATH);
            if (file == null) {
                // AOSP build environment?
                String build = System.getenv("ANDROID_BUILD_TOP");   //$NON-NLS-1$
                if (build != null) {
                    file = new File(build, "development/sdk/api-versions.xml" //$NON-NLS-1$
                            .replace('/', File.separatorChar));
                }
            }

            if (file == null || !file.exists()) {
                return null;
            } else {
                db = get(client, file);
            }
            sInstance = new WeakReference<ApiLookup>(db);
        }

        return db;
    }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:38,
代码来源:ApiLookup.java

示例15: ApiLookup

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/** Use one of the {@link #get} factory methods instead */
private ApiLookup(
        @NonNull LintClient client,
        @NonNull File xmlFile,
        @Nullable File binaryFile,
        @Nullable Api info) {
    mInfo = info;

    if (binaryFile != null) {
        readData(client, xmlFile, binaryFile);
    }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:13,
代码来源:ApiLookup.java

示例16: hasLayoutParams

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private static boolean hasLayoutParams(@NonNull JavaContext context, String name) {
    LintClient client = context.getClient();
    if (!client.supportsProjectResources()) {
        return true; // not certain
    }

    Project project = context.getProject();
    AbstractResourceRepository resources = client.getProjectResources(project, true);
    if (resources == null) {
        return true; // not certain
    }

    List<ResourceItem> items = resources.getResourceItem(ResourceType.LAYOUT, name);
    if (items == null || items.isEmpty()) {
        return false;
    }

    for (ResourceItem item : items) {
        ResourceFile source = item.getSource();
        if (source == null) {
            return true; // not certain
        }
        File file = source.getFile();
        if (file.exists()) {
            try {
                String s = context.getClient().readFile(file);
                if (hasLayoutParams(new StringReader(s))) {
                    return true;
                }
            } catch (Exception e) {
                context.log(e, "Could not read/parse inflated layout");
                return true; // not certain
            }
        }
    }

    return false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:39,
代码来源:LayoutInflationDetector.java

示例17: createCache

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private static boolean createCache(LintClient client, File xmlFile, File binaryData) {
    long begin = 0;
    if (WRITE_STATS) {
        begin = System.currentTimeMillis();
    }

    // Read in data
    List<String> lines;
    try {
        lines = Files.readLines(xmlFile, Charsets.UTF_8);
    } catch (IOException e) {
        client.log(e, "Can't read typo database file");
        return false;
    }

    if (WRITE_STATS) {
        long end = System.currentTimeMillis();
        System.out.println("Reading data structures took " + (end - begin) + " ms)");
    }

    try {
        writeDatabase(binaryData, lines);
        return true;
    } catch (IOException ioe) {
        client.log(ioe, "Can't write typo cache file");
    }

    return false;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:30,
代码来源:TypoLookup.java

示例18: TypoLookup

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/** Use one of the {@link #get} factory methods instead */
private TypoLookup(
        @NonNull LintClient client,
        @NonNull File xmlFile,
        @Nullable File binaryFile) {
    if (binaryFile != null) {
        readData(client, xmlFile, binaryFile);
    }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:TypoLookup.java

示例19: get

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
@NonNull
public static synchronized ExternalAnnotationRepository get(@NonNull LintClient client) {
    if (sSingleton == null) {
        HashSet<AndroidLibrary> seen = Sets.newHashSet();
        Collection<Project> projects = client.getKnownProjects();
        List<File> files = Lists.newArrayListWithExpectedSize(2);
        for (Project project : projects) {
            if (project.isGradleProject()) {
                Variant variant = project.getCurrentVariant();
                AndroidProject model = project.getGradleProjectModel();
                if (model != null && variant != null) {
                    Dependencies dependencies = variant.getMainArtifact().getDependencies();
                    for (AndroidLibrary library : dependencies.getLibraries()) {
                        addLibraries(files, library, seen);
                    }
                }
            }
        }

        File sdkAnnotations = client.findResource(SDK_ANNOTATIONS_PATH);
        if (sdkAnnotations == null) {
            // Until the SDK annotations are bundled in platform tools, provide
            // a fallback for Gradle builds to point to a locally installed version
            String path = System.getenv("SDK_ANNOTATIONS");
            if (path != null) {
                sdkAnnotations = new File(path);
                if (!sdkAnnotations.exists()) {
                    sdkAnnotations = null;
                }
            }
        }
        if (sdkAnnotations != null) {
            files.add(sdkAnnotations);
        }

        sSingleton = create(client, files);
    }

    return sSingleton;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:41,
代码来源:ExternalAnnotationRepository.java

示例20: create

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
@VisibleForTesting
@NonNull
static synchronized ExternalAnnotationRepository create(
        @Nullable LintClient client,
        @NonNull List<File> files) {
    long begin;
    if (DEBUG) {
        begin = System.currentTimeMillis();
    }

    List<AnnotationsDatabase> databases = Lists.newArrayListWithExpectedSize(files.size());
    for (File file : files) {
        try {
            AnnotationsDatabase database = getDatabase(file);
            if (database != null) {
                databases.add(database);
            }
        } catch (IOException ioe) {
            if (client != null) {
                client.log(ioe, "Could not read %1$s", file.getPath());
            } else {
                ioe.printStackTrace();
            }
        }
    }

    ExternalAnnotationRepository manager = new ExternalAnnotationRepository(databases);

    if (DEBUG) {
        long end = System.currentTimeMillis();
        System.out.println("Initialization of annotations took " + (end - begin) + " ms");
    }

    return manager;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:36,
代码来源:ExternalAnnotationRepository.java

示例21: getDatabase

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
@Nullable
private static AnnotationsDatabase getDatabase(
        @NonNull LintClient client,
        @NonNull File file) {
    try {
        return file.isFile() ? new AnnotationsDatabase(file) : null;
    } catch (IOException ioe) {
        client.log(ioe, "Could not read %1$s", file.getPath());
        return null;
    }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:12,
代码来源:ExternalAnnotationRepository.java

示例22: getConfiguration

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
@Override
protected TestConfiguration getConfiguration(LintClient client, Project project) {
    return new TestConfiguration(client, project, null) {
        @Override
        public boolean isEnabled(@NonNull Issue issue) {
            return super.isEnabled(issue) && (mEnabled == null || mEnabled.contains(issue));
        }
    };
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:10,
代码来源:GradleDetectorTest.java

示例23: testCapitalization

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
public void testCapitalization() throws Exception {
    LintClient client = new TestLintClient();
    // Make sure it can be read in
    TypoLookup db = TypoLookup.get(client, "de", null);
    assertNotNull(db);
    assertNotNull(db.getTypos("Andriod".getBytes(Charsets.UTF_8), 0, "Andriod".length()));
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:8,
代码来源:TypoLookupTest.java

示例24: createModuleProject

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
/** Creates a new module project */
@Nullable
private static LintModuleProject createModuleProject(@NonNull LintClient client, @NonNull Module module) {
  AndroidFacet facet = AndroidFacet.getInstance(module);
  File dir;

  if (facet != null) {
    final VirtualFile mainContentRoot = AndroidRootUtil.getMainContentRoot(facet);

    if (mainContentRoot == null) {
      return null;
    }
    dir = new File(FileUtil.toSystemDependentName(mainContentRoot.getPath()));
  } else {
    String moduleDirPath = AndroidRootUtil.getModuleDirPath(module);
    if (moduleDirPath == null) {
      return null;
    }
    dir = new File(FileUtil.toSystemDependentName(moduleDirPath));
  }
  LintModuleProject project;
  if (facet == null) {
    project = new LintModuleProject(client, dir, dir, module);
    AndroidFacet f = findAndroidFacetInProject(module.getProject());
    if (f != null) {
      project.mGradleProject = f.isGradleProject();
    }
  }
  else if (facet.isGradleProject()) {
    project = new LintGradleProject(client, dir, dir, facet);
  }
  else {
    project = new LintAndroidProject(client, dir, dir, facet);
  }
  client.registerProject(dir, project);
  return project;
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:38,
代码来源:IntellijLintProject.java

示例25: LintAndroidProject

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private LintAndroidProject(@NonNull LintClient client, @NonNull File dir, @NonNull File referenceDir, @NonNull AndroidFacet facet) {
  super(client, dir, referenceDir, facet.getModule());
  myFacet = facet;

  mGradleProject = false;
  mLibrary = myFacet.isLibraryProject();

  AndroidPlatform platform = AndroidPlatform.getInstance(myFacet.getModule());
  if (platform != null) {
    mBuildSdk = platform.getApiLevel();
  }
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:13,
代码来源:IntellijLintProject.java

示例26: LintGradleLibraryProject

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
private LintGradleLibraryProject(@NonNull LintClient client,
                                 @NonNull File dir,
                                 @NonNull File referenceDir,
                                 @NonNull AndroidLibrary library) {
  super(client, dir, referenceDir);
  myLibrary = library;

  mLibrary = true;
  mMergeManifests = true;
  mReportIssues = false;
  mGradleProject = true;
  mDirectLibraries = Collections.emptyList();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:14,
代码来源:IntellijLintProject.java

示例27: TestConfiguration

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
public TestConfiguration(
    @NonNull LintClient client,
    @Nullable Project project,
    @Nullable Configuration parent,
    @NonNull File configFile) {
    super(client, project, parent, configFile);
}
 

开发者ID:winterDroid,
项目名称:droidcon_lint,
代码行数:8,
代码来源:AbstractCheckTest.java

示例28: getConfiguration

点赞 2

import com.android.tools.lint.client.api.LintClient; //导入依赖的package包/类
protected TestConfiguration getConfiguration(LintClient client, Project project) {
    return new TestConfiguration(client, project, null);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:4,
代码来源:LintDetectorTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)