import static org.junit.Assert.*; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExternalResource; public class TestSomething { @Rule public ResourceFile res = new ResourceFile("/res.txt"); @Test public void test() throws Exception { assertTrue(res.getContent().length() > 0); assertTrue(res.getFile().exists()); } }
@NonNull @Override public Location resolve() { // TODO: Look up the exact item location more // closely ResourceFile source = item.getSource(); assert source != null : item; return create(source.getFile()); }
private static boolean checkResourceRepository( @NonNull AbstractResourceRepository resources, @NonNull String name) { List<ResourceItem> items = resources.getResourceItem(ResourceType.DRAWABLE, name); if (items == null) { return false; } // Check if at least one drawable with this name is a vector. for (ResourceItem item : items) { ResourceFile source = item.getSource(); if (source == null) { return false; } File file = source.getFile(); if (!file.getPath().endsWith(SdkConstants.DOT_XML)) { continue; } return SdkConstants.TAG_VECTOR.equals(XmlUtils.getRootTagName(file)); } return false; } }
@Nullable protected Collection<String> getViewTags( @NonNull Context context, @NonNull ResourceItem item) { // Check view tag in this file. Can I do it cheaply? Try with // an XML pull parser. Or DOM if we have multiple resources looked // up? ResourceFile source = item.getSource(); if (source != null) { File file = source.getFile(); Multimap<String,String> map = getIdToTagsIn(context, file); if (map != null) { return map.get(item.getName()); } } return null; }
ResourceFile source = item.getSource(); if (source != null) { File file = source.getFile(); if (file.getParentFile().getName().startsWith(FD_RES_VALUES)) { if (mDeclaredIds == null) {
ResourceFile source = item.getSource(); if (source != null && LintUtils.isSameResourceFile(context.file, source.getFile())) { continue; + context.file.getName(); assert source != null; File otherFile = source.getFile(); String otherName = otherFile.getParentFile().getName() + File.separator + otherFile.getName();
@Nullable protected Collection<String> getViewTags( @NonNull Context context, @NonNull ResourceItem item) { // Check view tag in this file. Can I do it cheaply? Try with // an XML pull parser. Or DOM if we have multiple resources looked // up? ResourceFile source = item.getSource(); if (source != null) { File file = source.getFile(); Multimap<String,String> map = getIdToTagsIn(context, file); if (map != null) { return map.get(item.getName()); } } return null; }
ResourceFile source = item.getSource(); if (source != null) { File file = source.getFile(); if (file.getParentFile().getName().startsWith(FD_RES_VALUES)) { if (mDeclaredIds == null) {
ResourceFile source = item.getSource(); if (source != null && LintUtils.isSameResourceFile(context.file, source.getFile())) { continue; + context.file.getName(); assert source != null; File otherFile = source.getFile(); String otherName = otherFile.getParentFile().getName() + File.separator + otherFile.getName();
continue; File file = source.getFile(); try { String xml = Files.toString(file, Charsets.UTF_8);
continue; File file = source.getFile(); try { String xml = Files.toString(file, Charsets.UTF_8);
String message = String.format( "Should use \"`sp`\" instead of \"`dp`\" for text sizes (`%1$s` is defined as `%2$s` in `%3$s`", value, dimenValue, sourceFile.getFile()); context.report(DP_ISSUE, attribute, context.getLocation(attribute),
String message = String.format( "Should use \"`sp`\" instead of \"`dp`\" for text sizes (`%1$s` is defined as `%2$s` in `%3$s`", value, dimenValue, sourceFile.getFile()); context.report(DP_ISSUE, attribute, context.getLocation(attribute),
return true; // not certain File file = source.getFile(); if (file.exists()) { try {
File file = source.getFile(); if (file.exists()) { try {
"Margin values should not be negative " + "(`%1$s` is defined as `%2$s` in `%3$s`", value, dimenValue, sourceFile.getFile()); context.report(ISSUE, scope, context.getLocation(scope),
"Margin values should not be negative " + "(`%1$s` is defined as `%2$s` in `%3$s`", value, dimenValue, sourceFile.getFile()); context.report(ISSUE, scope, context.getLocation(scope),