001/*
002 * Copyright (C) 2022 - 2023, 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 * @author Ashley Scopes
029 * @since 3.0.0
030 */
031@API(since = "3.0.0", status = Status.STABLE)
032public enum DebuggingInfo {
033  LINES,
034  VARS,
035  SOURCE;
036
037  /**
038   * Return a set of none of the debugger info flags.
039   *
040   * @return a set containing no debugger flags.
041   */
042  public static Set<DebuggingInfo> none() {
043    return EnumSet.noneOf(DebuggingInfo.class);
044  }
045
046  /**
047   * Return a set of the given debugger info flags.
048   *
049   * @param flag  the first flag.
050   * @param flags additional flags.
051   * @return the set of the debugger info flags.
052   */
053  public static Set<DebuggingInfo> just(DebuggingInfo flag, DebuggingInfo... flags) {
054    return EnumSet.of(flag, flags);
055  }
056
057  /**
058   * Return a set of all the debugger info flags.
059   *
060   * @return a set containing all the debugger flags.
061   */
062  public static Set<DebuggingInfo> all() {
063    return EnumSet.allOf(DebuggingInfo.class);
064  }
065}