public String getContents() { if (contents == null) { contents = client.readFile(file); } return contents; }
@Override public String readFile(File file) { return mDelegate.readFile(file); }
private void addJavaDeclarations(Context context, File file) { String s = context.client.readFile(file); String[] lines = s.split("\n"); //$NON-NLS-1$ String currentType = null;
@Override @NonNull public CharSequence readFile(@NonNull File file) { return mDelegate.readFile(file); }
@NonNull @Override protected String readText(@NonNull File file) { if (context != null) { return context.getClient().readFile(file).toString(); } try { return Files.toString(file, UTF_8); } catch (IOException e) { return ""; // Lint API } }
private void scanJavaFile(Context context, File file, String pkg) { String fileName = file.getName(); if (fileName.endsWith(DOT_JAVA) && file.exists()) { String clz = fileName.substring(0, fileName.length() - DOT_JAVA.length()); String fqn = pkg + '.' + clz; if (mActivities.contains(fqn) || fqn.endsWith("Activity")) { //$NON-NLS-1$ String code = context.client.readFile(file); scanLayoutReferences(code, fqn); scanThemeReferences(code, fqn); } } else if (file.isDirectory()) { File[] children = file.listFiles(); if (children != null) { String subPackage; if (pkg == null) { subPackage = ""; } else if (pkg.length() == 0) { subPackage = file.getName(); } else { subPackage = pkg + '.' + file.getName(); } for (File child : children) { scanJavaFile(context, child, subPackage); } } } }
/** * Returns the contents of the file. This may not be the contents of the * file on disk, since it delegates to the {@link LintClient}, which in turn * may decide to return the current edited contents of the file open in an * editor. * * @return the contents of the given file, or null if an error occurs. */ @Nullable public CharSequence getContents() { if (contents == null) { contents = driver.getClient().readFile(file); } return contents; }
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));
@NonNull Set<String> revocable, @NonNull File manifest) { CharSequence xml = client.readFile(manifest); Document document = CharSequences.parseDocumentSilently(xml, true); if (document == null) {
@Nullable private Multimap<String, String> getIdToTagsIn(@NonNull Context context, @NonNull File file) { if (!file.getPath().endsWith(DOT_XML)) { return null; } if (mFileIdMap == null) { mFileIdMap = Maps.newHashMap(); } Multimap<String, String> map = mFileIdMap.get(file); if (map == null) { map = ArrayListMultimap.create(); mFileIdMap.put(file, map); CharSequence xml = context.getClient().readFile(file); // TODO: Use pull parser instead for better performance! // See LayoutInflationDetector#hasLayoutParams for an example Document document = CharSequences.parseDocumentSilently(xml, true); if (document != null && document.getDocumentElement() != null) { addViewTags(map, document.getDocumentElement()); } } return map; }
@Nullable private Multimap<String, String> getIdToTagsIn(@NonNull Context context, @NonNull File file) { if (!file.getPath().endsWith(DOT_XML)) { return null; } if (mFileIdMap == null) { mFileIdMap = Maps.newHashMap(); } Multimap<String, String> map = mFileIdMap.get(file); if (map == null) { map = ArrayListMultimap.create(); mFileIdMap.put(file, map); String xml = context.getClient().readFile(file); // TODO: Use pull parser instead for better performance! Document document = XmlUtils.parseDocumentSilently(xml, true); if (document != null && document.getDocumentElement() != null) { addViewTags(map, document.getDocumentElement()); } } return map; }
@NonNull Set<String> revocable, @NonNull File manifest) { Document document = XmlUtils.parseDocumentSilently(client.readFile(manifest), true); if (document == null) { return;
/** * Returns the contents of the source file for this class file, if found. * * @return the source contents, or "" */ @NonNull public CharSequence getSourceContents() { if (sourceContents == null) { File sourceFile = getSourceFile(); if (sourceFile != null) { sourceContents = getClient().readFile(sourceFile); } if (sourceContents == null) { sourceContents = ""; } } return sourceContents; }
return; String properties = context.getClient().readFile(propertyFile); int i = properties.indexOf(PROGUARD_CONFIG); if (i == -1) {
private static Location refineLocation(Context context, Location location, String formatString, int substringStart, int substringEnd) { Position startLocation = location.getStart(); Position endLocation = location.getEnd(); if (startLocation != null && endLocation != null) { int startOffset = startLocation.getOffset(); int endOffset = endLocation.getOffset(); if (startOffset >= 0) { String contents = context.getClient().readFile(location.getFile()); if (endOffset <= contents.length() && startOffset < endOffset) { int formatOffset = contents.indexOf(formatString, startOffset); if (formatOffset != -1 && formatOffset <= endOffset) { return Location.create(location.getFile(), contents, formatOffset + substringStart, formatOffset + substringEnd); } } } } return location; }
return; CharSequence properties = context.getClient().readFile(propertyFile); int i = indexOf(properties, PROGUARD_CONFIG); if (i == -1) {
if (file.exists()) { try { String s = context.getClient().readFile(file); if (hasLayoutParams(new StringReader(s))) { return true;
private static Location refineLocation(Context context, Location location, String formatString, int substringStart, int substringEnd) { Position startLocation = location.getStart(); Position endLocation = location.getEnd(); if (startLocation != null && endLocation != null) { int startOffset = startLocation.getOffset(); int endOffset = endLocation.getOffset(); if (startOffset >= 0) { CharSequence contents = context.getClient().readFile(location.getFile()); if (endOffset <= contents.length() && startOffset < endOffset) { int formatOffset = indexOf(contents, formatString, startOffset); if (formatOffset != -1 && formatOffset <= endOffset) { return Location.create(location.getFile(), contents, formatOffset + substringStart, formatOffset + substringEnd); } } } } return location; }
if (file.exists()) { try { CharSequence s = client.readFile(file); Reader reader = CharSequences.getReader(s, true); if (hasLayoutParams(reader)) {
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) {