@Override public void log(Throwable exception, String format, Object... args) { mDelegate.log(exception, format, args); }
@Override public File findResource(@NonNull String relativePath) { return mDelegate.findResource(relativePath); }
public String getContents() { if (contents == null) { contents = client.readFile(file); } return contents; }
boolean mkdirs = parentFile.mkdirs(); if (!mkdirs) { client.log(null, "Couldn't create %1$s", parentFile); return; writer.write(TAG_ISSUES); writer.write(" format=\"4\""); String revision = client.getClientRevision(); if (revision != null) { writer.write(String.format(" by=\"lint %1$s\"", revision)); writer.close(); } catch (IOException ioe) { client.log(ioe, null);
/** * Adds in any custom lint rules and returns the result as a new issue registry, * or the same one if no custom rules were found * * @param registry the main registry to add rules to * @return a new registry containing the passed in rules plus any custom rules, * or the original registry if no custom rules were found */ public IssueRegistry addCustomLintRules(@NonNull IssueRegistry registry) { List<File> jarFiles = findGlobalRuleJars(); if (!jarFiles.isEmpty()) { List<IssueRegistry> registries = Lists.newArrayListWithExpectedSize(jarFiles.size()); registries.add(registry); for (File jarFile : jarFiles) { try { registries.add(JarFileIssueRegistry.get(this, jarFile)); } catch (Throwable e) { log(e, "Could not load custom rule jar file %1$s", jarFile); } } if (registries.size() > 1) { // the first item is the passed in registry itself return new CompositeIssueRegistry(registries); } } return registry; }
/** * Returns all the {@link IAndroidTarget} versions installed in the user's SDK install * area. * * @return all the installed targets */ @NonNull public IAndroidTarget[] getTargets() { if (targets == null) { AndroidSdkHandler sdkHandler = getSdk(); if (sdkHandler != null) { ProgressIndicator logger = getRepositoryLogger(); Collection<IAndroidTarget> targets = sdkHandler.getAndroidTargetManager(logger) .getTargets(logger); this.targets = targets.toArray(new IAndroidTarget[targets.size()]); } else { targets = new IAndroidTarget[0]; } } return targets; }
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(); client.log(null, "The API database file %1$s does not exist", binaryData); return null;
URL url = new URL(query); URLConnection connection = client.openConnection(url); if (connection == null) { return null; client.closeConnection(connection); client.log(ioe, "Could not connect to maven central to look up the " + "latest available version for %1$s", dependency); return null;
client.log(e, null); continue; client.log(e, "Could not read jar file contents from %1$s", jarFile); } finally { try { byte[] bytes = client.readBytes(file); entries.add(new ClassEntry(file, null /* jarFile*/, binDir, bytes)); } catch (IOException e) { client.log(e, null); client.log(null, "Ignoring class path entry %1$s", classPathEntry);
File classpathFile = new File(projectDir, ".classpath"); //$NON-NLS-1$ if (classpathFile.exists()) { String classpathXml = readFile(classpathFile); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); InputSource is = new InputSource(new StringReader(classpathXml)); log(null, null);
@Override public void report(Context context, Issue issue, Location location, String message, Object data) { Configuration configuration = context.configuration; if (!configuration.isEnabled(issue)) { if (issue != IssueRegistry.PARSER_ERROR) { mDelegate.log(null, "Incorrect detector reported disabled issue %1$s", issue.toString()); } return; } if (configuration.isIgnored(context, issue, location, message, data)) { return; } Severity severity = configuration.getSeverity(issue); if (severity == Severity.IGNORE) { return; } mDelegate.report(context, issue, location, message, data); }
private void checkIndividualJavaFiles( @NonNull Project project, @Nullable Project main, @NonNull List<Detector> checks, @NonNull List<File> files) { JavaParser javaParser = client.getJavaParser(project); if (javaParser == null) { client.log(null, "No java parser provided to lint: not running Java checks"); return; } List<JavaContext> contexts = Lists.newArrayListWithExpectedSize(files.size()); for (File file : files) { if (file.isFile() && file.getPath().endsWith(DOT_JAVA)) { contexts.add(new JavaContext(this, project, main, file, javaParser)); } } if (contexts.isEmpty()) { return; } visitJavaFiles(checks, javaParser, contexts); }
buildSdk = Integer.parseInt(versionString); } catch (NumberFormatException nufe) { client.log(Severity.WARNING, null, "Unexpected build target format: %1$s", target); Project libraryPrj = client.getProject(libraryDir, libraryReferenceDir); directLibraries.add(libraryPrj); client.log(ioe, "Initializing project state"); buildSdk = getClient().getHighestKnownApiLevel();
} else { manifestMinSdk = SdkVersionInfo.getVersion(version, client.getTargets()); client.log(ioe, null);
jarFiles.addAll(client.findRuleJars(project)); for (Project library : project.getAllLibraries()) { jarFiles.addAll(client.findRuleJars(library)); jarFiles.addAll(client.findGlobalRuleJars()); registries.add(registry); } catch (Throwable e) { client.log(e, "Could not load custom rule jar file %1$s", jarFile);
private static boolean hasLayoutParams(@NonNull JavaContext context, String name) { LintClient client = context.getClient(); if (!client.supportsProjectResources()) { return true; // not certain AbstractResourceRepository resources = client.getProjectResources(project, true); if (resources == null) { return true; // not certain if (file.exists()) { try { String s = context.getClient().readFile(file); if (hasLayoutParams(new StringReader(s))) { return true;
} else { AndroidSdkHandler sdk = context.getClient().getSdk(); if (sdk == null) { return; context.getClient().getRepositoryLogger()); if (pkgInfo == null) { return; if (currentFiles != null && currentFiles.size() == 1) { File file = currentFiles.get(0); CharSequence contents = context.getClient().readFile(file); int firstLineEnd = indexOf(contents, '\n'); if (firstLineEnd == -1) {
File sdkHome = context.getClient().getSdkHome(); FileOp fileOp = FileOpUtils.create(); File repository = try { int api = Integer.parseInt(target); if (api < context.getClient().getHighestKnownApiLevel()) { context.report(TARGET_NEWER, element, context.getLocation(targetSdkVersionNode), if (fullBackupNode != null && fullBackupNode.getValue().startsWith(PREFIX_RESOURCE_REF) && context.getClient().supportsProjectResources()) { AbstractResourceRepository resources = context.getClient() .getResourceRepository(context.getProject(), true, false); ResourceUrl url = ResourceUrl.parse(fullBackupNode.getValue()); if (url != null && !url.framework
private static boolean hasLayoutParams(@NonNull JavaContext context, String name) { LintClient client = context.getClient(); if (!client.supportsProjectResources()) { return true; // not certain AbstractResourceRepository resources = client.getResourceRepository(project, true, false); if (resources == null) { return true; // not certain if (file.exists()) { try { CharSequence s = client.readFile(file); Reader reader = CharSequences.getReader(s, true); if (hasLayoutParams(reader)) {
ClassLoader loader = client.createUrlClassLoader(new URL[]{url}, JarFileIssueRegistry.class.getClassLoader()); Class<?> registryClass = Class.forName(className, true, loader); client.log(Severity.ERROR, null, "Custom lint rule jar %1$s does not contain a valid registry manifest key " + "(%2$s).\n" +