本文整理汇总了Java中com.sun.tools.javac.util.Options.put方法的典型用法代码示例。如果您正苦于以下问题:Java Options.put方法的具体用法?Java Options.put怎么用?Java Options.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.Options
的用法示例。
在下文中一共展示了Options.put方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileManager
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
JavaFileManager getFileManager(String classpathProperty,
boolean symFileKind,
boolean zipFileIndexKind)
throws IOException {
Context ctx = new Context();
Options options = Options.instance(ctx);
options.put("useOptimizedZip",
Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));
if (symFileKind == IGNORE_SYMBOL_FILE)
options.put("ignore.symbol.file", "true");
JavacFileManager fm = new JavacFileManager(ctx, false, null);
List<File> path = getPath(System.getProperty(classpathProperty));
fm.setLocation(CLASS_PATH, path);
return fm;
}
示例2: getFileManager
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
JavaFileManager getFileManager(String classpathProperty,
boolean symFileKind,
boolean zipFileIndexKind)
throws IOException {
Context ctx = new Context();
// uugh, ugly back door, should be cleaned up, someday
if (zipFileIndexKind == USE_ZIP_FILE_INDEX)
System.clearProperty("useJavaUtilZip");
else
System.setProperty("useJavaUtilZip", "true");
Options options = Options.instance(ctx);
if (symFileKind == IGNORE_SYMBOL_FILE)
options.put("ignore.symbol.file", "true");
JavacFileManager fm = new JavacFileManager(ctx, false, null);
List<File> path = getPath(System.getProperty(classpathProperty));
fm.setLocation(CLASS_PATH, path);
return fm;
}
示例3: initContext
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
private void initContext() {
//initialize compiler's default locale
context.put(Locale.class, locale);
if (!addModules.isEmpty()) {
String names = String.join(",", addModules);
Options opts = Options.instance(context);
String prev = opts.get(Option.ADD_MODULES);
opts.put(Option.ADD_MODULES, (prev == null) ? names : prev + "," + names);
}
}
示例4: createFileManager
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
JavacFileManager createFileManager(boolean useSymbolFile) {
Context ctx = new Context();
Options options = Options.instance(ctx);
if (!useSymbolFile) {
options.put("ignore.symbol.file", "true");
}
return new JavacFileManager(ctx, false, null);
}
示例5: createFileManager
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
Context ctx = new Context();
Options options = Options.instance(ctx);
options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
if (!useSymbolFile) {
options.put("ignore.symbol.file", "true");
}
return new JavacFileManager(ctx, false, null);
}
示例6: createFileManager
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
Context c = new Context();
Options options = Options.instance(c);
options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
if (!useSymbolFile) {
options.put("ignore.symbol.file", "true");
}
return new JavacFileManager(c, false, null);
}
示例7: test
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
static void test(boolean genEndPos) throws IOException {
Context context = new Context();
Options options = Options.instance(context);
options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");
Log log = Log.instance(context);
log.multipleErrors = true;
JavacFileManager.preRegister(context);
ParserFactory pfac = ParserFactory.instance(context);
final String text =
"public class Foo {\n"
+ " public static void main(String[] args) {\n"
+ " if (args.length == 0)\n"
+ " System.out.println(\"no args\");\n"
+ " else\n"
+ " System.out.println(args.length + \" args\");\n"
+ " }\n"
+ "}\n";
JavaFileObject fo = new StringJavaFileObject("Foo", text);
log.useSource(fo);
CharSequence cs = fo.getCharContent(true);
Parser parser = pfac.newParser(cs, false, genEndPos, false);
JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
log.setEndPosTable(fo, tree.endPositions);
TreeScanner ts = new LogTester(log, tree.endPositions);
ts.scan(tree);
check(log.nerrors, 4, "errors");
check(log.nwarnings, 4, "warnings");
}
示例8: test
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
static void test(boolean genEndPos) throws IOException {
Context context = new Context();
Options options = Options.instance(context);
options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");
Log log = Log.instance(context);
log.multipleErrors = true;
JavacFileManager.preRegister(context);
Scanner.Factory sfac = Scanner.Factory.instance(context);
Parser.Factory pfac = Parser.Factory.instance(context);
final String text =
"public class Foo {\n"
+ " public static void main(String[] args) {\n"
+ " if (args.length == 0)\n"
+ " System.out.println(\"no args\");\n"
+ " else\n"
+ " System.out.println(args.length + \" args\");\n"
+ " }\n"
+ "}\n";
JavaFileObject fo = new StringJavaFileObject("Foo", text);
log.useSource(fo);
Scanner s = sfac.newScanner(fo.getCharContent(true));
Parser parser = pfac.newParser(s, false, genEndPos);
JCTree.JCCompilationUnit tree = parser.compilationUnit();
log.setEndPosTable(fo, tree.endPositions);
TreeScanner ts = new LogTester(log, tree.endPositions);
ts.scan(tree);
check(log.nerrors, 4, "errors");
check(log.nwarnings, 4, "warnings");
}
示例9: createFileManager
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) {
// javac should really not be using system properties like this
// -- it should really be using (hidden) options -- but until then
// take care to leave system properties as we find them, so as not
// to adversely affect other tests that might follow.
String prev = System.getProperty("useJavaUtilZip");
boolean resetProperties = false;
try {
if (useJavaUtilZip) {
System.setProperty("useJavaUtilZip", "true");
resetProperties = true;
} else if (System.getProperty("useJavaUtilZip") != null) {
System.getProperties().remove("useJavaUtilZip");
resetProperties = true;
}
Context c = new Context();
if (!useSymbolFile) {
Options options = Options.instance(c);
options.put("ignore.symbol.file", "true");
}
return new JavacFileManager(c, false, null);
} finally {
if (resetProperties) {
if (prev == null) {
System.getProperties().remove("useJavaUtilZip");
} else {
System.setProperty("useJavaUtilZip", prev);
}
}
}
}
示例10: test
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
static void test(boolean genEndPos) throws Exception {
Context context = new Context();
Options options = Options.instance(context);
options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m");
Log log = Log.instance(context);
Factory diagnosticFactory = JCDiagnostic.Factory.instance(context);
Field defaultErrorFlagsField =
JCDiagnostic.Factory.class.getDeclaredField("defaultErrorFlags");
defaultErrorFlagsField.setAccessible(true);
Set<DiagnosticFlag> defaultErrorFlags =
(Set<DiagnosticFlag>) defaultErrorFlagsField.get(diagnosticFactory);
defaultErrorFlags.add(DiagnosticFlag.MULTIPLE);
JavacFileManager.preRegister(context);
ParserFactory pfac = ParserFactory.instance(context);
final String text =
"public class Foo {\n"
+ " public static void main(String[] args) {\n"
+ " if (args.length == 0)\n"
+ " System.out.println(\"no args\");\n"
+ " else\n"
+ " System.out.println(args.length + \" args\");\n"
+ " }\n"
+ "}\n";
JavaFileObject fo = new StringJavaFileObject("Foo", text);
log.useSource(fo);
CharSequence cs = fo.getCharContent(true);
Parser parser = pfac.newParser(cs, false, genEndPos, false);
JCTree.JCCompilationUnit tree = parser.parseCompilationUnit();
log.setEndPosTable(fo, tree.endPositions);
TreeScanner ts = new LogTester(log, tree.endPositions);
ts.scan(tree);
check(log.nerrors, 4, "errors");
check(log.nwarnings, 4, "warnings");
}
示例11: setUp
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
Context context = new Context();
Options compOpts = Options.instance(context);
compOpts.put("-sourcepath", "src/test/java");
new PublicMessager(context, "test",
new PrintWriter(new LogWriter(Level.SEVERE), true),
new PrintWriter(new LogWriter(Level.WARNING), true),
new PrintWriter(new LogWriter(Level.FINE), true)
);
final JavadocTool javadocTool = JavadocTool.make0(context);
final ListBuffer<String> javaNames = new ListBuffer<>();
javaNames.append("org.maxur.ldoc.model.domain.subdomainA");
javaNames.append("org.maxur.ldoc.model.domain.subdomainB");
javaNames.append("org.maxur.ldoc.model.domain.subdomainB.subdir");
javaNames.append("org.maxur.ldoc.model.domain.subdomainC");
final ListBuffer<String[]> options = new ListBuffer<>();
final ListBuffer<String> packageNames = new ListBuffer<>();
final ListBuffer<String> excludedPackages = new ListBuffer<>();
rootMaker = () -> {
try {
return javadocTool.getRootDocImpl(
"en",
"",
new ModifierFilter(ModifierFilter.ALL_ACCESS),
javaNames.toList(),
options.toList(),
Collections.emptyList(),
false,
packageNames.toList(),
excludedPackages.toList(),
false,
false,
false
);
} catch (IOException e) {
throw new IllegalStateException(e);
}
};
}
示例12: createFileManager
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
JavacFileManager createFileManager(boolean useOptimizedZip) {
Context ctx = new Context();
Options options = Options.instance(ctx);
options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
return new JavacFileManager(ctx, false, null);
}
示例13: process
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
/** Process the option (with arg). Return true if error detected.
*/
public boolean process(Options options, String option, String arg) {
if (options != null)
options.put(option, arg);
return false;
}
示例14: EasyDoclet
import com.sun.tools.javac.util.Options; //导入方法依赖的package包/类
protected EasyDoclet(File sourceDirectory, String[] packageNames, File[] fileNames)
{
this.sourceDirectory = sourceDirectory;
this.packageNames = packageNames;
this.fileNames = fileNames;
Context context = new Context();
Options compOpts = Options.instance(context);
if (getSourceDirectory().exists())
{
log.fine("Using source path: " + getSourceDirectory().getAbsolutePath());
compOpts.put("-sourcepath", getSourceDirectory().getAbsolutePath());
}
else
{
log.info("Ignoring non-existant source path, check your source directory argument");
}
ListBuffer javaNames = new ListBuffer();
for (File fileName : fileNames)
{
log.fine("Adding file to documentation path: " + fileName.getAbsolutePath());
javaNames.append(fileName.getPath());
}
ListBuffer subPackages = new ListBuffer();
for (String packageName : packageNames)
{
log.fine("Adding sub-packages to documentation path: " + packageName);
subPackages.append(packageName);
}
new PublicMessager(context, getApplicationName(), new PrintWriter(new LogWriter(Level.SEVERE), true), new PrintWriter(
new LogWriter(Level.WARNING), true), new PrintWriter(new LogWriter(Level.FINE), true));
JavadocTool javadocTool = JavadocTool.make0(context);
try
{
rootDoc = javadocTool.getRootDocImpl("", null, new ModifierFilter(ModifierFilter.ALL_ACCESS), javaNames.toList(),
new ListBuffer().toList(), false, subPackages.toList(), new ListBuffer().toList(), false, false, false);
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
if (log.isLoggable(Level.FINEST))
{
for (ClassDoc classDoc : getRootDoc().classes())
{
log.finest("Parsed Javadoc class source: " + classDoc.position() + " with inline tags: " + classDoc.inlineTags().length);
}
}
}