Home | History | Annotate | Download | only in api
      1 /*
      2  * Copyright (C) 2011 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.tools.lint.client.api;
     18 
     19 import com.android.annotations.NonNull;
     20 import com.android.tools.lint.detector.api.Context;
     21 import com.google.common.annotations.Beta;
     22 
     23 /**
     24  * Interface implemented by listeners to be notified of lint events
     25  * <p>
     26  * <b>NOTE: This is not a public or final API; if you rely on this be prepared
     27  * to adjust your code for the next tools release.</b>
     28  */
     29 @Beta
     30 public interface LintListener {
     31     /** The various types of events provided to lint listeners */
     32     public enum EventType {
     33         /** A lint check is about to begin */
     34         STARTING,
     35 
     36         /** Lint is about to check the given project, see {@link Context#getProject()} */
     37         SCANNING_PROJECT,
     38 
     39         /** Lint is about to check the given library project, see {@link Context#getProject()} */
     40         SCANNING_LIBRARY_PROJECT,
     41 
     42         /** Lint is about to check the given file, see {@link Context#file} */
     43         SCANNING_FILE,
     44 
     45         /** A new pass was initiated */
     46         NEW_PHASE,
     47 
     48         /** The lint check was canceled */
     49         CANCELED,
     50 
     51         /** The lint check is done */
     52         COMPLETED,
     53     };
     54 
     55     /**
     56      * Notifies listeners that the event of the given type has occurred.
     57      * Additional information, such as the file being scanned, or the project
     58      * being scanned, is available in the {@link Context} object (except for the
     59      * {@link EventType#STARTING}, {@link EventType#CANCELED} or
     60      * {@link EventType#COMPLETED} events which are fired outside of project
     61      * contexts.)
     62      *
     63      * @param driver the driver running through the checks
     64      * @param type the type of event that occurred
     65      * @param context the context providing additional information
     66      */
     67     public void update(@NonNull LintDriver driver, @NonNull EventType type,
     68             @NonNull Context context);
     69 }
     70