@Override public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mFileToArrayCount = ArrayListMultimap.create(30, 5); } }
@Override public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mIds = new HashSet<String>(); } }
@Override public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mDeclarations = new HashSet<String>(300); mReferences = new HashSet<String>(300); } }
@Override public void afterCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { // Store this layout's set of ids for full project analysis in afterCheckProject mFileToIds.put(context.file, mIds); mIds = null; } }
@Override public void afterCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { // Store this layout's set of ids for full project analysis in afterCheckProject mFileToIds.put(context.file, mIds); mIds = null; } }
@Override public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mIds = new HashSet<>(); } }
@Override public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mFileToIds = new HashMap<>(); mIncludes = new HashMap<>(); } }
@Override public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mFileToArrayCount = ArrayListMultimap.create(30, 5); } }
@Override public void beforeCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { mFileToIds = new HashMap<File, Set<String>>(); mIncludes = new HashMap<File, List<String>>(); } }
@Override public void afterCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { // Store this layout's set of ids for full project analysis in afterCheckProject if (context.getProject().getReportIssues() && mNames != null && !mNames.isEmpty()) { mFileToNames.put(context.file, mNames); Element root = ((XmlContext) context).document.getDocumentElement(); if (root != null) { String locale = root.getAttributeNS(TOOLS_URI, ATTR_LOCALE); if (locale != null && !locale.isEmpty()) { if (mFileToLocale == null) { mFileToLocale = Maps.newHashMap(); } mFileToLocale.put(context.file, locale); } // Add in English here if not specified? Worry about false positives listing "en" explicitly } } mNames = null; } }
@Override public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mNames = new HashSet<>(); } // Convention seen in various projects mIgnoreFile = context.file.getName().startsWith("donottranslate") || ResourceUsageModel.isAnalyticsFile(context.file); if (!context.getProject().getReportIssues()) { mIgnoreFile = true; } }
@Override public void afterCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { // Store this layout's set of ids for full project analysis in afterCheckProject if (context.getProject().getReportIssues() && mNames != null && !mNames.isEmpty()) { mFileToNames.put(context.file, mNames); Element root = ((XmlContext) context).document.getDocumentElement(); if (root != null) { String locale = root.getAttributeNS(TOOLS_URI, ATTR_LOCALE); if (locale != null && !locale.isEmpty()) { if (mFileToLocale == null) { mFileToLocale = Maps.newHashMap(); } mFileToLocale.put(context.file, locale); } // Add in English here if not specified? Worry about false positives listing "en" explicitly } } mNames = null; } }
@Override public void beforeCheckFile(@NonNull Context context) { if (context.getPhase() == 1) { mNames = new HashSet<String>(); } // Convention seen in various projects mIgnoreFile = context.file.getName().startsWith("donottranslate") //$NON-NLS-1$ || UnusedResourceDetector.isAnalyticsFile(context); if (!context.getProject().getReportIssues()) { mIgnoreFile = true; } }
@Override public void afterCheckProject(@NonNull Context context) { int phase = context.getPhase(); if (phase == 1 && mApplicableResources != null) { // We found resources for the string "Cancel"; perform a second pass // where we check layout text attributes against these strings. context.getDriver().requestRepeat(this, Scope.RESOURCE_FILE_SCOPE); } }
@Override public void afterCheckProject(@NonNull Context context) { int phase = context.getPhase(); if (phase == 1 && mApplicableResources != null) { // We found resources for the string "Cancel"; perform a second pass // where we check layout text attributes against these strings. context.getDriver().requestRepeat(this, Scope.RESOURCE_FILE_SCOPE); } }
@Override public void afterCheckProject(@NonNull Context context) { // Process checks in two phases: // Phase 1: Gather styles and includes (styles are encountered after the layouts // so we can't do it in a single phase, and includes can be affected by includes from // layouts we haven't seen yet) // Phase 2: Process layouts, using gathered style and include data, and mark layouts // not known. // if (context.getPhase() == 1) { checkSizeSetInTheme(); context.requestRepeat(this, Scope.RESOURCE_FILE_SCOPE); } }
@Override public void afterCheckProject(@NonNull Context context) { // Process checks in two phases: // Phase 1: Gather styles and includes (styles are encountered after the layouts // so we can't do it in a single phase, and includes can be affected by includes from // layouts we haven't seen yet) // Phase 2: Process layouts, using gathered style and include data, and mark layouts // not known. // if (context.getPhase() == 1) { checkSizeSetInTheme(); context.requestRepeat(this, Scope.RESOURCE_FILE_SCOPE); } }
@Override public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { // NOTE - this will look for the presence of translation strings. // If you create a resource folder but don't actually place a file in it // we won't detect that, but it seems like a smaller problem. checkTranslations(context); mFileToNames = null; if (mMissingLocations != null || mExtraLocations != null) { context.getDriver().requestRepeat(this, Scope.ALL_RESOURCES_SCOPE); } } else { assert context.getPhase() == 2; reportMap(context, MISSING, mMissingLocations); reportMap(context, EXTRA, mExtraLocations); mMissingLocations = null; mExtraLocations = null; mDescriptions = null; } }
@Override public void afterCheckProject(@NonNull Context context) { if (context.getPhase() == 1) { // NOTE - this will look for the presence of translation strings. // If you create a resource folder but don't actually place a file in it // we won't detect that, but it seems like a smaller problem. checkTranslations(context); mFileToNames = null; if (mMissingLocations != null || mExtraLocations != null) { context.getDriver().requestRepeat(this, Scope.ALL_RESOURCES_SCOPE); } } else { assert context.getPhase() == 2; reportMap(context, MISSING, mMissingLocations); reportMap(context, EXTRA, mExtraLocations); mMissingLocations = null; mExtraLocations = null; mDescriptions = null; } }
if (context != null) { resource.setDeclared(context.getProject().getReportIssues()); if (context.getPhase() == 2 && unused.contains(resource)) { if (xmlContext != null && xmlContext.getDriver().isSuppressed(xmlContext, getIssue(resource), node)) {