com.android.tools.lint.detector.api.Detector Java Examples
The following examples show how to use
com.android.tools.lint.detector.api.Detector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Requests another pass through the data for the given detector. This is * typically done when a detector needs to do more expensive computation, * but it only wants to do this once it <b>knows</b> that an error is * present, or once it knows more specifically what to check for. * * @param detector the detector that should be included in the next pass. * Note that the lint runner may refuse to run more than a couple * of runs. * @param scope the scope to be revisited. This must be a subset of the * current scope ({@link #getScope()}, and it is just a performance hint; * in particular, the detector should be prepared to be called on other * scopes as well (since they may have been requested by other detectors). * You can pall null to indicate "all". */ public void requestRepeat(@NonNull Detector detector, @Nullable EnumSet<Scope> scope) { if (mRepeatingDetectors == null) { mRepeatingDetectors = new ArrayList<Detector>(); } mRepeatingDetectors.add(detector); if (scope != null) { if (mRepeatScope == null) { mRepeatScope = scope; } else { mRepeatScope = EnumSet.copyOf(mRepeatScope); mRepeatScope.addAll(scope); } } else { mRepeatScope = Scope.ALL; } }
Example #2
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 6 votes |
@Nullable private static List<Detector> union( @Nullable List<Detector> list1, @Nullable List<Detector> list2) { if (list1 == null) { return list2; } else if (list2 == null) { return list1; } else { // Use set to pick out unique detectors, since it's possible for there to be overlap, // e.g. the DuplicateIdDetector registers both a cross-resource issue and a // single-file issue, so it shows up on both scope lists: Set<Detector> set = new HashSet<Detector>(list1.size() + list2.size()); set.addAll(list1); set.addAll(list2); return new ArrayList<Detector>(set); } }
Example #3
Source File: LintDetectorTest.java From javaide with GNU General Public License v3.0 | 5 votes |
protected final Detector getDetectorInstance() { if (mDetector == null) { mDetector = getDetector(); } return mDetector; }
Example #4
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 5 votes |
private void checkResFolder( @NonNull Project project, @Nullable Project main, @NonNull File res, @NonNull List<ResourceXmlDetector> xmlChecks, @Nullable List<Detector> dirChecks, @Nullable List<Detector> binaryChecks) { File[] resourceDirs = res.listFiles(); if (resourceDirs == null) { return; } // Sort alphabetically such that we can process related folder types at the // same time, and to have a defined behavior such that detectors can rely on // predictable ordering, e.g. layouts are seen before menus are seen before // values, etc (l < m < v). Arrays.sort(resourceDirs); for (File dir : resourceDirs) { ResourceFolderType type = ResourceFolderType.getFolderType(dir.getName()); if (type != null) { checkResourceFolder(project, main, dir, type, xmlChecks, dirChecks, binaryChecks); } if (mCanceled) { return; } } }
Example #5
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 5 votes |
private void checkJava( @NonNull Project project, @Nullable Project main, @NonNull List<File> sourceFolders, @NonNull List<Detector> checks) { JavaParser javaParser = mClient.getJavaParser(project); if (javaParser == null) { mClient.log(null, "No java parser provided to lint: not running Java checks"); return; } assert !checks.isEmpty(); // Gather all Java source files in a single pass; more efficient. List<File> sources = new ArrayList<File>(100); for (File folder : sourceFolders) { gatherJavaFiles(folder, sources); } if (!sources.isEmpty()) { JavaVisitor visitor = new JavaVisitor(javaParser, checks); List<JavaContext> contexts = Lists.newArrayListWithExpectedSize(sources.size()); for (File file : sources) { JavaContext context = new JavaContext(this, project, main, file, javaParser); contexts.add(context); } visitor.prepare(contexts); for (JavaContext context : contexts) { fireEvent(EventType.SCANNING_FILE, context); visitor.visitFile(context); if (mCanceled) { return; } } visitor.dispose(); } }
Example #6
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 5 votes |
private void checkPropertyFile(Project project, Project main, List<Detector> detectors, String relativePath) { File file = new File(project.getDir(), relativePath); if (file.exists()) { Context context = new Context(this, project, main, file); fireEvent(EventType.SCANNING_FILE, context); for (Detector detector : detectors) { if (detector.appliesTo(context, file)) { detector.beforeCheckFile(context); detector.run(context); detector.afterCheckFile(context); } } } }
Example #7
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 5 votes |
private void checkProperties(Project project, Project main) { List<Detector> detectors = mScopeDetectors.get(Scope.PROPERTY_FILE); if (detectors != null) { checkPropertyFile(project, main, detectors, FN_LOCAL_PROPERTIES); checkPropertyFile(project, main, detectors, FD_GRADLE_WRAPPER + separator + FN_GRADLE_WRAPPER_PROPERTIES); } }
Example #8
Source File: LintDriver.java From javaide with GNU General Public License v3.0 | 5 votes |
private void computeDetectors(@NonNull Project project) { // Ensure that the current visitor is recomputed mCurrentFolderType = null; mCurrentVisitor = null; Configuration configuration = project.getConfiguration(this); mScopeDetectors = new EnumMap<Scope, List<Detector>>(Scope.class); mApplicableDetectors = mRegistry.createDetectors(mClient, configuration, mScope, mScopeDetectors); validateScopeList(); }
Example #9
Source File: RelativeOverlapDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new RelativeOverlapDetector(); }
Example #10
Source File: MainTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { // Sample issue to check by the main driver return new AccessibilityDetector(); }
Example #11
Source File: ParcelDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new ParcelDetector(); }
Example #12
Source File: SharedPrefsDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new SharedPrefsDetector(); }
Example #13
Source File: AddJavascriptInterfaceDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new AddJavascriptInterfaceDetector(); }
Example #14
Source File: UselessViewDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new UselessViewDetector(); }
Example #15
Source File: ArraySizeDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new ArraySizeDetector(); }
Example #16
Source File: SystemPermissionsDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new SystemPermissionsDetector(); }
Example #17
Source File: DetectMissingPrefixTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new DetectMissingPrefix(); }
Example #18
Source File: InjectedFieldInJobNotTransientDetectorTest.java From cathode with Apache License 2.0 | 4 votes |
@Override protected Detector getDetector() { return new InjectedFieldInJobNotTransientDetector(); }
Example #19
Source File: GradleDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new GroovyGradleDetector(); }
Example #20
Source File: CleanupDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new CleanupDetector(); }
Example #21
Source File: SecurityDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new SecurityDetector(); }
Example #22
Source File: EcjParserTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new SdCardDetector(); }
Example #23
Source File: OverrideDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new OverrideDetector(); }
Example #24
Source File: PreferenceActivityDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new PreferenceActivityDetector(); }
Example #25
Source File: HardcodedDebugModeDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new HardcodedDebugModeDetector(); }
Example #26
Source File: HandlerDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new HandlerDetector(); }
Example #27
Source File: TypoLookupTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { fail("This is not used in the TypoLookupTest"); return null; }
Example #28
Source File: ManifestTypoDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new ManifestTypoDetector(); }
Example #29
Source File: PrivateKeyDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new PrivateKeyDetector(); }
Example #30
Source File: WrongLocationDetectorTest.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override protected Detector getDetector() { return new WrongLocationDetector(); }