/*
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.tools.javac.main;
import com.sun.tools.javac.code.Lint;
import com.sun.tools.javac.code.Source;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.jvm.Target;
import com.sun.tools.javac.main.JavacOption.HiddenOption;
import com.sun.tools.javac.main.JavacOption.Option;
import com.sun.tools.javac.main.JavacOption.XOption;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Options;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.EnumSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import javax.lang.model.SourceVersion;
import static com.sun.tools.javac.main.OptionName.*;
/**
* TODO: describe com.sun.tools.javac.main.RecognizedOptions
*
*
This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own
* risk. This code and its internal interfaces are subject to change
* or deletion without notice.
*/
public class RecognizedOptions {
private RecognizedOptions() {}
public interface OptionHelper {
void setOut(PrintWriter out);
void error(String key, Object... args);
void printVersion();
void printFullVersion();
void printHelp();
void printXhelp();
void addFile(File f);
void addClassName(String s);
}
public static class GrumpyHelper implements OptionHelper {
public void setOut(PrintWriter out) {
throw new IllegalArgumentException();
}
public void error(String key, Object... args) {
throw new IllegalArgumentException(Main.getLocalizedString(key, args));
}
public void printVersion() {
throw new IllegalArgumentException();
}
public void printFullVersion() {
throw new IllegalArgumentException();
}
public void printHelp() {
throw new IllegalArgumentException();
}
public void printXhelp() {
throw new IllegalArgumentException();
}
public void addFile(File f) {
throw new IllegalArgumentException(f.getPath());
}
public void addClassName(String s) {
throw new IllegalArgumentException(s);
}
}
static Set javacOptions = EnumSet.of(
G,
G_NONE,
G_CUSTOM,
XLINT,
XLINT_CUSTOM,
NOWARN,
VERBOSE,
DEPRECATION,
CLASSPATH,
CP,
SOURCEPATH,
BOOTCLASSPATH,
XBOOTCLASSPATH_PREPEND,
XBOOTCLASSPATH_APPEND,
XBOOTCLASSPATH,
EXTDIRS,
DJAVA_EXT_DIRS,
ENDORSEDDIRS,
DJAVA_ENDORSED_DIRS,
PROC,
PROCESSOR,
PROCESSORPATH,
D,
S,
IMPLICIT,
ENCODING,
SOURCE,
TARGET,
VERSION,
FULLVERSION,
DIAGS,
HELP,
A,
X,
J,
MOREINFO,
WERROR,
// COMPLEXINFERENCE,
PROMPT,
DOE,
PRINTSOURCE,
WARNUNCHECKED,
XMAXERRS,
XMAXWARNS,
XSTDOUT,
XPKGINFO,
XPRINT,
XPRINTROUNDS,
XPRINTPROCESSORINFO,
XPREFER,
O,
XJCOV,
XD,
AT,
SOURCEFILE);
static Set javacFileManagerOptions = EnumSet.of(
CLASSPATH,
CP,
SOURCEPATH,
BOOTCLASSPATH,
XBOOTCLASSPATH_PREPEND,
XBOOTCLASSPATH_APPEND,
XBOOTCLASSPATH,
EXTDIRS,
DJAVA_EXT_DIRS,
ENDORSEDDIRS,
DJAVA_ENDORSED_DIRS,
PROCESSORPATH,
D,
S,
ENCODING,
SOURCE);
static Set javacToolOptions = EnumSet.of(
G,
G_NONE,
G_CUSTOM,
XLINT,
XLINT_CUSTOM,
NOWARN,
VERBOSE,
DEPRECATION,
PROC,
PROCESSOR,
IMPLICIT,
SOURCE,
TARGET,
// VERSION,
// FULLVERSION,
// HELP,
A,
// X,
// J,
MOREINFO,
WERROR,
// COMPLEXINFERENCE,
PROMPT,
DOE,
PRINTSOURCE,
WARNUNCHECKED,
XMAXERRS,
XMAXWARNS,
// XSTDOUT,
XPKGINFO,
XPRINT,
XPRINTROUNDS,
XPRINTPROCESSORINFO,
XPREFER,
O,
XJCOV,
XD);
static Option[] getJavaCompilerOptions(OptionHelper helper) {
return getOptions(helper, javacOptions);
}
public static Option[] getJavacFileManagerOptions(OptionHelper helper) {
return getOptions(helper, javacFileManagerOptions);
}
public static Option[] getJavacToolOptions(OptionHelper helper) {
return getOptions(helper, javacToolOptions);
}
static Option[] getOptions(OptionHelper helper, Set desired) {
ListBuffer