本文整理汇总了Java中com.sun.tools.javac.main.OptionName类的典型用法代码示例。如果您正苦于以下问题:Java OptionName类的具体用法?Java OptionName怎么用?Java OptionName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OptionName类属于com.sun.tools.javac.main包,在下文中一共展示了OptionName类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
if (args.length == 0) {
System.out.println("Usage: Supply a file name to print.");
return;
}
Context context = new Context();
Options.instance(context).put(OptionName.ENCODING, "UTF-8");
JavaCompiler compiler = new JavaCompiler(context);
compiler.genEndPos = true;
compiler.keepComments = true;
@SuppressWarnings("deprecation") JCCompilationUnit cu = compiler.parse(args[0]);
JcTreePrinter printer = new JcTreePrinter(true);
printer.visit(cu);
System.out.println(printer);
}
示例2: parseWithLombok
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
protected JCTree parseWithLombok(Source source) {
Context context = new Context();
Options.instance(context).put(OptionName.ENCODING, "UTF-8");
JavaCompiler compiler = new JavaCompiler(context);
compiler.genEndPos = true;
compiler.keepComments = true;
JCCompilationUnit cu = compiler.parse(new ContentBasedJavaFileObject(source.getName(), source.getRawInput()));
JcTreeConverter converter = new JcTreeConverter();
JcTreeBuilder builder = new JcTreeBuilder();
converter.visit(cu);
builder.visit(converter.getResult());
return builder.get();
}
示例3: getOutputLocation
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
private File getOutputLocation(File dir, OptionName defaultOptionName) {
if (dir != null)
return dir;
String arg = options.get(defaultOptionName);
if (arg == null)
return null;
return new File(arg);
}
示例4: getSource
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
protected Source getSource() {
String sourceName = options.get(OptionName.SOURCE);
Source source = null;
if (sourceName != null)
source = Source.lookup(sourceName);
return (source != null ? source : Source.DEFAULT);
}
示例5: getEncodingName
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
public String getEncodingName() {
String encName = options.get(OptionName.ENCODING);
if (encName == null)
return getDefaultEncodingName();
else
return encName;
}
示例6: getIntOption
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
private int getIntOption(Options options, OptionName optionName, int defaultValue) {
String s = options.get(optionName);
try {
if (s != null) {
int n = Integer.parseInt(s);
return (n <= 0 ? Integer.MAX_VALUE : n);
}
} catch (NumberFormatException e) {
// silently ignore ill-formed numbers
}
return defaultValue;
}
示例7: getEncodingName
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
protected String getEncodingName() {
String encName = options.get(OptionName.ENCODING);
if (encName == null)
return getDefaultEncodingName();
else
return encName;
}
示例8: parseWithTargetCompiler
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
protected JCTree parseWithTargetCompiler(Source source) {
Context context = new Context();
Options.instance(context).put(OptionName.ENCODING, "UTF-8");
JavaCompiler compiler = new JavaCompiler(context);
compiler.genEndPos = true;
compiler.keepComments = true;
JCCompilationUnit cu = compiler.parse(new ContentBasedJavaFileObject(source.getName(), source.getRawInput()));
return cu;
}
示例9: parseWithTargetCompiler
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
protected Node parseWithTargetCompiler(Source source) {
Context context = new Context();
Options.instance(context).put(OptionName.ENCODING, "UTF-8");
CommentCatcher catcher = CommentCatcher.create(context);
JavaCompiler compiler = catcher.getCompiler();
JCCompilationUnit cu = compiler.parse(new ContentBasedJavaFileObject(source.getName(), source.getRawInput()));
JcTreeConverter converter = new JcTreeConverter();
converter.visit(cu);
return converter.getResultWithJavadoc(catcher.getComments(cu));
}
示例10: get
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
/**
* Get the value for an option.
*/
public String get(OptionName name) {
return values.get(name.optionName);
}
示例11: isSet
import com.sun.tools.javac.main.OptionName; //导入依赖的package包/类
/**
* Check if the value for an option has been set.
*/
public boolean isSet(OptionName name) {
return (values.get(name.optionName) != null);
}