• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.metalava
18 
19 import com.android.tools.metalava.model.IssueConfiguration
20 
21 enum class ReleaseType(val flagName: String, private val displayName: String = flagName) {
22     DEV("current", "development") {
23         /**
24          * Customization of the severities to apply when doing compatibility checking against the
25          * current version of the API. Corresponds to the same flags passed into doclava's error
26          * check this way:
27          * args: "-error 2 -error 3 -error 4 -error 5 -error 6 " +
28          * "-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 " +
29          * "-error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 " +
30          * "-error 25 -error 26 -error 27",
31          */
getIssueConfigurationnull32         override fun getIssueConfiguration(): IssueConfiguration {
33             return super.getIssueConfiguration().apply {
34                 error(Issues.ADDED_CLASS)
35                 error(Issues.ADDED_FIELD)
36                 error(Issues.ADDED_FINAL_UNINSTANTIABLE)
37                 error(Issues.ADDED_INTERFACE)
38                 error(Issues.ADDED_METHOD)
39                 error(Issues.ADDED_PACKAGE)
40                 error(Issues.CHANGED_ABSTRACT)
41                 error(Issues.CHANGED_CLASS)
42                 error(Issues.CHANGED_DEPRECATED)
43                 error(Issues.CHANGED_SCOPE)
44                 error(Issues.CHANGED_SYNCHRONIZED)
45                 error(Issues.CHANGED_THROWS)
46                 error(Issues.REMOVED_FINAL)
47             }
48         }
49     },
50 
51     RELEASED("released", "released") {
52         /**
53          * Customization of the severities to apply when doing compatibility checking against the
54          * previously released stable version of the API. Corresponds to the same flags passed into
55          * doclava's error check this way:
56          * args: "-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 " +
57          * "-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 " +
58          * "-error 16 -error 17 -error 18 -error 31",
59          */
getIssueConfigurationnull60         override fun getIssueConfiguration(): IssueConfiguration {
61             return super.getIssueConfiguration().apply {
62                 error(Issues.ADDED_ABSTRACT_METHOD)
63                 hide(Issues.ADDED_CLASS)
64                 hide(Issues.ADDED_FIELD)
65                 hide(Issues.ADDED_FINAL_UNINSTANTIABLE)
66                 hide(Issues.ADDED_INTERFACE)
67                 hide(Issues.ADDED_METHOD)
68                 hide(Issues.ADDED_PACKAGE)
69                 hide(Issues.CHANGED_DEPRECATED)
70                 hide(Issues.CHANGED_SYNCHRONIZED)
71                 hide(Issues.REMOVED_FINAL)
72             }
73         }
74     };
75 
76     /** Returns the error configuration to use for the given release type */
getIssueConfigurationnull77     open fun getIssueConfiguration(): IssueConfiguration {
78         return IssueConfiguration().apply {
79             error(Issues.ADDED_FINAL)
80             error(Issues.CHANGED_STATIC)
81             error(Issues.CHANGED_SUPERCLASS)
82             error(Issues.CHANGED_TRANSIENT)
83             error(Issues.CHANGED_TYPE)
84             error(Issues.CHANGED_VALUE)
85             error(Issues.CHANGED_VOLATILE)
86             error(Issues.REMOVED_CLASS)
87             error(Issues.REMOVED_FIELD)
88             error(Issues.REMOVED_INTERFACE)
89             error(Issues.REMOVED_METHOD)
90             error(Issues.REMOVED_PACKAGE)
91             error(Issues.ADDED_REIFIED)
92         }
93     }
94 
toStringnull95     override fun toString(): String = displayName
96 }
97