001/* 002 * Copyright (C) 2022 - 2024, the original author or authors. 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 */ 016package io.github.ascopes.jct.compilers; 017 018import java.util.EnumSet; 019import java.util.Set; 020import org.apiguardian.api.API; 021import org.apiguardian.api.API.Status; 022 023/** 024 * An enum representing the various types of debugger info that can be included in compilations. 025 * 026 * <p>This corresponds to the {@code -g} flag in the OpenJDK Javac implementation. 027 * 028 * <p>Debugging info flags are designed to be combined using the helper methods on this class. 029 * 030 * @author Ashley Scopes 031 * @since 3.0.0 032 */ 033@API(since = "3.0.0", status = Status.STABLE) 034public enum DebuggingInfo { 035 036 /** 037 * Include line numbers. 038 */ 039 LINES, 040 041 /** 042 * Include local variable names. 043 */ 044 VARS, 045 046 /** 047 * Include source code. 048 */ 049 SOURCE; 050 051 /** 052 * Return a set of none of the debugger info flags. 053 * 054 * @return a set containing no debugger flags. 055 */ 056 public static Set<DebuggingInfo> none() { 057 return EnumSet.noneOf(DebuggingInfo.class); 058 } 059 060 /** 061 * Return a set of the given debugger info flags. 062 * 063 * @param flag the first flag. 064 * @param flags additional flags. 065 * @return the set of the debugger info flags. 066 */ 067 public static Set<DebuggingInfo> just(DebuggingInfo flag, DebuggingInfo... flags) { 068 return EnumSet.of(flag, flags); 069 } 070 071 /** 072 * Return a set of all the debugger info flags. 073 * 074 * @return a set containing all the debugger flags. 075 */ 076 public static Set<DebuggingInfo> all() { 077 return EnumSet.allOf(DebuggingInfo.class); 078 } 079}