if (isXmlFile || LintUtils.isBitmapFile(file)) { String fileName = file.getName(); String parentName = file.getParentFile().getName();
@Override public void beforeCheckFile(@NonNull Context context) { File file = context.file; boolean isXmlFile = LintUtils.isXmlFile(file); if (!isXmlFile && !LintUtils.isBitmapFile(file)) { return; } String parentName = file.getParentFile().getName(); int dash = parentName.indexOf('-'); if (dash != -1 || FD_RES_VALUES.equals(parentName)) { return; } ResourceFolderType folderType = ResourceFolderType.getFolderType(parentName); if (folderType == null) { return; } List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(folderType); if (types.isEmpty()) { return; } ResourceType type = types.get(0); String resourceName = getResourceFieldName(getBaseName(file.getName())); if (isPrivate(context, type, resourceName)) { String message = createOverrideErrorMessage(context, type, resourceName); Location location = Location.create(file); context.report(ISSUE, location, message); } }
@Override public void beforeCheckFile(@NonNull Context context) { File file = context.file; boolean isXmlFile = LintUtils.isXmlFile(file); if (!isXmlFile && !LintUtils.isBitmapFile(file)) { return; } String parentName = file.getParentFile().getName(); int dash = parentName.indexOf('-'); if (dash != -1 || FD_RES_VALUES.equals(parentName)) { return; } ResourceFolderType folderType = ResourceFolderType.getFolderType(parentName); if (folderType == null) { return; } List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes(folderType); if (types.isEmpty()) { return; } ResourceType type = types.get(0); String resourceName = getResourceFieldName(getBaseName(file.getName())); if (isPrivate(context, type, resourceName)) { String message = createOverrideErrorMessage(context, type, resourceName); Location location = Location.create(file); context.report(ISSUE, location, message); } }
} else if (binaryChecks != null && file.isFile() && LintUtils.isBitmapFile(file)) {
} else if (endsWithIgnoreCase(path, ".js")) { tokenizeJs(from, Files.toString(file, UTF_8)); } else if (file.isFile() && !LintUtils.isBitmapFile(file)) { tokenizeUnknownBinary(file);
if (LintUtils.isBitmapFile(context.file)) { return;
public void visitBinaryResource( @Nullable ResourceFolderType folderType, @NonNull File file) { Resource from = null; if (folderType != ResourceFolderType.VALUES) { // Record resource for the whole file List<ResourceType> types = FolderTypeRelationship.getRelatedResourceTypes( folderType); ResourceType type = types.get(0); assert type != ResourceType.ID : folderType; String name = LintUtils.getBaseName(file.getName()); from = declareResource(type, name, null); } if (folderType == ResourceFolderType.RAW) { // Is this an HTML, CSS or JavaScript document bundled with the app? // If so tokenize and look for resource references. String path = file.getPath(); if (endsWithIgnoreCase(path, ".html") || endsWithIgnoreCase(path, ".htm")) { tokenizeHtml(from, readText(file)); } else if (endsWithIgnoreCase(path, ".css")) { tokenizeCss(from, readText(file)); } else if (endsWithIgnoreCase(path, ".js")) { tokenizeJs(from, readText(file)); } else if (file.isFile() && !LintUtils.isBitmapFile(file)) { tokenizeUnknownBinary(from, file); } } }
fireEvent(EventType.SCANNING_FILE, context); visitor.visitFile(context, file); } else if (binaryChecks != null && (LintUtils.isBitmapFile(file) || type == ResourceFolderType.RAW)) { ResourceContext context = new ResourceContext(this, project, main, file, type);