001 /*
002 * Copyright 2010-2015 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.kotlin.codegen;
018
019 public class ClassBuilderMode {
020 public final boolean generateBodies;
021 public final boolean generateMetadata;
022 public final boolean generateSourceRetentionAnnotations;
023 public final boolean generateMultiFileFacadePartClasses;
024
025 private ClassBuilderMode(
026 boolean generateBodies,
027 boolean generateMetadata,
028 boolean generateSourceRetentionAnnotations,
029 boolean generateMultiFileFacadePartClasses
030 ) {
031 this.generateBodies = generateBodies;
032 this.generateMetadata = generateMetadata;
033 this.generateSourceRetentionAnnotations = generateSourceRetentionAnnotations;
034 this.generateMultiFileFacadePartClasses = generateMultiFileFacadePartClasses;
035 }
036
037 public static ClassBuilderMode full(boolean generateSourceRetentionAnnotations) {
038 return generateSourceRetentionAnnotations ? KAPT : FULL;
039 }
040
041 /**
042 * Full function bodies
043 */
044 private final static ClassBuilderMode FULL = new ClassBuilderMode(
045 /* bodies = */ true,
046 /* metadata = */ true,
047 /* sourceRetention = */ false,
048 /* generateMultiFileFacadePartClasses = */ true);
049
050 /**
051 * Generating light classes: Only function signatures
052 */
053 public final static ClassBuilderMode LIGHT_CLASSES = new ClassBuilderMode(
054 /* bodies = */ false,
055 /* metadata = */ false,
056 /* sourceRetention = */ true,
057 /* generateMultiFileFacadePartClasses = */ false);
058
059 /**
060 * Function signatures + metadata (to support incremental compilation with kapt)
061 */
062 public final static ClassBuilderMode KAPT = new ClassBuilderMode(
063 /* bodies = */ false,
064 /* metadata = */ true,
065 /* sourceRetention = */ true,
066 /* generateMultiFileFacadePartClasses = */ false);
067
068 /**
069 * Function signatures + metadata (to support incremental compilation with kapt)
070 */
071 public final static ClassBuilderMode KAPT3 = new ClassBuilderMode(
072 /* bodies = */ false,
073 /* metadata = */ true,
074 /* sourceRetention = */ true,
075 /* generateMultiFileFacadePartClasses = */ true);
076 }