/** * Returns the current phase number. The first pass is numbered 1. Only one pass * will be performed, unless a {@link Detector} calls {@link #requestRepeat}. * * @return the current phase, usually 1 */ public int getPhase() { return driver.getPhase(); }
@Override public void beforeCheckProject(@NonNull Context context) { if (context.getDriver().getPhase() == 1) { mFileToNames = new HashMap<File, Set<String>>(); } }
@Override public void beforeCheckProject(@NonNull Context context) { if (context.getDriver().getPhase() == 1) { mFileToNames = new HashMap<>(); } }
@Override public void afterCheckProject(@NonNull Context context) { LintDriver driver = context.getDriver(); if (driver.getPhase() == 1) { // First phase: gather all the ids and look for consistency issues. // If any are found, request location computation in phase 2 by // writing the ids needed for each layout in the {@link #mLocations} map. for (Map.Entry<String,List<Pair<File,Map<String,String>>>> entry : mMap.entrySet()) { String layout = entry.getKey(); List<Pair<File, Map<String, String>>> files = entry.getValue(); if (files.size() < 2) { // No consistency problems for files that don't have resource variations continue; } checkConsistentIds(layout, files); } if (mLocations != null) { driver.requestRepeat(this, Scope.ALL_RESOURCES_SCOPE); } } else { // Collect results and print if (!mLocations.isEmpty()) { reportErrors(context); } } }
@Override public void afterCheckProject(@NonNull Context context) { LintDriver driver = context.getDriver(); if (driver.getPhase() == 1) { // First phase: gather all the ids and look for consistency issues. // If any are found, request location computation in phase 2 by // writing the ids needed for each layout in the {@link #mLocations} map. for (Map.Entry<String,List<Pair<File,Map<String,String>>>> entry : mMap.entrySet()) { String layout = entry.getKey(); List<Pair<File, Map<String, String>>> files = entry.getValue(); if (files.size() < 2) { // No consistency problems for files that don't have resource variations continue; } checkConsistentIds(layout, files); } if (mLocations != null) { driver.requestRepeat(this, Scope.ALL_RESOURCES_SCOPE); } } else { // Collect results and print if (!mLocations.isEmpty()) { reportErrors(context); } } }
@Nullable @Override public JavaElementVisitor createPsiVisitor(@NonNull JavaContext context) { if (context.getDriver().getPhase() == 1) { return new UnusedResourceVisitor(); } else { // Second pass, computing resource declaration locations: No need to look at Java return null; } }
@Override public void afterCheckProject(@NonNull Context context) { if (mHasAcquire && !mHasRelease && context.getDriver().getPhase() == 1) { // Gather positions of the acquire calls context.getDriver().requestRepeat(this, Scope.CLASS_FILE_SCOPE); } }
@Override public void afterCheckProject(@NonNull Context context) { if (mHasAcquire && !mHasRelease && context.getDriver().getPhase() == 1) { // Gather positions of the acquire calls context.getDriver().requestRepeat(this, Scope.CLASS_FILE_SCOPE); } }
int phase = context.getDriver().getPhase(); if (phase == 1) {
int phase = context.getDriver().getPhase(); if (phase == 1) {
if (parent.endsWith(name) && parent.equals(STYLE_RESOURCE_PREFIX + name) && context.isEnabled(CYCLE) && context.getDriver().getPhase() == 1) { context.report(CYCLE, parentNode, context.getLocation(parentNode), String.format("Style `%1$s` should not extend itself", name)); && parent.startsWith(name, STYLE_RESOURCE_PREFIX.length()) && parent.startsWith(".", STYLE_RESOURCE_PREFIX.length() + name.length()) && context.isEnabled(CYCLE) && context.getDriver().getPhase() == 1) { context.report(CYCLE, parentNode, context.getLocation(parentNode), String.format("Potential cycle: `%1$s` is the implied parent of `%2$s` and " + if (context.isEnabled(CRASH) && context.getDriver().getPhase() == 1) { for (Element item : LintUtils.getChildren(element)) { if ("android:id".equals(item.getAttribute(ATTR_NAME))) { + LAYOUT_RESOURCE_PREFIX.length() && context.isEnabled(CYCLE) && context.getDriver().getPhase() == 1) { String message = String.format("Layout `%1$s` should not include itself", currentLayout); && context.getDriver().getPhase() == 1) { context.report(CYCLE, child, context.getLocation(child), String.format("Color `%1$s` should not reference itself",
if (parent.endsWith(name) && parent.equals(STYLE_RESOURCE_PREFIX + name) && context.isEnabled(CYCLE) && context.getDriver().getPhase() == 1) { context.report(CYCLE, parentNode, context.getLocation(parentNode), String.format("Style `%1$s` should not extend itself", name)); && parent.startsWith(name, STYLE_RESOURCE_PREFIX.length()) && parent.startsWith(".", STYLE_RESOURCE_PREFIX.length() + name.length()) && context.isEnabled(CYCLE) && context.getDriver().getPhase() == 1) { context.report(CYCLE, parentNode, context.getLocation(parentNode), String.format("Potential cycle: `%1$s` is the implied parent of `%2$s` and " + if (context.isEnabled(CRASH) && context.getDriver().getPhase() == 1) { for (Element item : LintUtils.getChildren(element)) { if ("android:id".equals(item.getAttribute(ATTR_NAME))) { + LAYOUT_RESOURCE_PREFIX.length() && context.isEnabled(CYCLE) && context.getDriver().getPhase() == 1) { String message = String.format("Layout `%1$s` should not include itself", currentLayout); && context.getDriver().getPhase() == 1) { context.report(CYCLE, child, context.getLocation(child), String.format("Color `%1$s` should not reference itself",