本文整理汇总了Java中com.sun.tools.javac.util.Names.instance方法的典型用法代码示例。如果您正苦于以下问题:Java Names.instance方法的具体用法?Java Names.instance怎么用?Java Names.instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.Names
的用法示例。
在下文中一共展示了Names.instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DocEnv
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
/**
* Constructor
*
* @param context Context for this javadoc instance.
*/
protected DocEnv(Context context) {
context.put(docEnvKey, this);
this.context = context;
messager = Messager.instance0(context);
syms = Symtab.instance(context);
finder = JavadocClassFinder.instance(context);
enter = JavadocEnter.instance(context);
names = Names.instance(context);
externalizableSym = syms.enterClass(syms.java_base, names.fromString("java.io.Externalizable"));
chk = Check.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
if (fileManager instanceof JavacFileManager) {
((JavacFileManager)fileManager).setSymbolFileEnabled(false);
}
// Default. Should normally be reset with setLocale.
this.doclocale = new DocLocale(this, "", breakiterator);
source = Source.instance(context);
}
示例2: init
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
private void init(Context context) {
modules = Modules.instance(context);
attr = Attr.instance(context);
enter = Enter.instance(context);
elements = JavacElements.instance(context);
log = Log.instance(context);
resolve = Resolve.instance(context);
treeMaker = TreeMaker.instance(context);
memberEnter = MemberEnter.instance(context);
names = Names.instance(context);
types = Types.instance(context);
docTreeMaker = DocTreeMaker.instance(context);
parser = ParserFactory.instance(context);
syms = Symtab.instance(context);
fileManager = context.get(JavaFileManager.class);
JavacTask t = context.get(JavacTask.class);
if (t instanceof JavacTaskImpl)
javacTaskImpl = (JavacTaskImpl) t;
}
示例3: enterClassFiles
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
/** Enter a set of generated class files. */
private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
ClassReader reader = ClassReader.instance(context);
Names names = Names.instance(context);
List<ClassSymbol> list = List.nil();
for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
Name name = names.fromString(entry.getKey());
JavaFileObject file = entry.getValue();
if (file.getKind() != JavaFileObject.Kind.CLASS)
throw new AssertionError(file);
ClassSymbol cs;
if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) {
Name packageName = Convert.packagePart(name);
PackageSymbol p = reader.enterPackage(packageName);
if (p.package_info == null)
p.package_info = reader.enterClass(Convert.shortName(name), p);
cs = p.package_info;
if (cs.classfile == null)
cs.classfile = file;
} else
cs = reader.enterClass(name, file);
list = list.prepend(cs);
}
return list.reverse();
}
示例4: DocEnv
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
/**
* Constructor
*
* @param context Context for this javadoc instance.
*/
protected DocEnv(Context context) {
context.put(docEnvKey, this);
this.context = context;
messager = Messager.instance0(context);
syms = Symtab.instance(context);
reader = JavadocClassReader.instance0(context);
enter = JavadocEnter.instance0(context);
names = Names.instance(context);
externalizableSym = reader.enterClass(names.fromString("java.io.Externalizable"));
chk = Check.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
if (fileManager instanceof JavacFileManager) {
((JavacFileManager)fileManager).setSymbolFileEnabled(false);
}
// Default. Should normally be reset with setLocale.
this.doclocale = new DocLocale(this, "", breakiterator);
source = Source.instance(context);
}
示例5: run
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
public void run() {
int id = checkCount.incrementAndGet();
JavaSource source = new JavaSource(id);
JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc,
Arrays.asList("-g"), null, Arrays.asList(source));
Context context = ct.getContext();
Symtab syms = Symtab.instance(context);
Names names = Names.instance(context);
Types types = Types.instance(context);
ct.addTaskListener(new Indifier(syms, names, types));
try {
ct.generate();
} catch (Throwable t) {
t.printStackTrace();
throw new AssertionError(
String.format("Error thrown when compiling following code\n%s",
source.source));
}
if (dc.diagFound) {
throw new AssertionError(
String.format("Diags found when compiling following code\n%s\n\n%s",
source.source, dc.printDiags()));
}
verifyBytecode(id);
}
示例6: DocEnv
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
/**
* Constructor
*
* @param context Context for this javadoc instance.
*/
protected DocEnv(Context context) {
context.put(docEnvKey, this);
this.context = context;
messager = Messager.instance0(context);
syms = Symtab.instance(context);
finder = JavadocClassFinder.instance(context);
enter = JavadocEnter.instance(context);
names = Names.instance(context);
externalizableSym = syms.enterClass(syms.java_base, names.fromString("java.io.Externalizable"));
chk = Check.instance(context);
types = com.sun.tools.javac.code.Types.instance(context);
fileManager = context.get(JavaFileManager.class);
if (fileManager instanceof JavacFileManager) {
((JavacFileManager)fileManager).setSymbolFileEnabled(false);
}
docTrees = JavacTrees.instance(context);
source = Source.instance(context);
elements = JavacElements.instance(context);
typeutils = JavacTypes.instance(context);
elementToTreePath = new HashMap<>();
}
示例7: run
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
public void run(JavaCompiler comp) {
JavaSource source = new JavaSource();
JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, null, dc,
Arrays.asList("-g"), null, Arrays.asList(source));
Context context = ct.getContext();
Symtab syms = Symtab.instance(context);
Names names = Names.instance(context);
Types types = Types.instance(context);
ct.addTaskListener(new Indifier(syms, names, types));
try {
ct.generate();
} catch (Throwable t) {
t.printStackTrace();
throw new AssertionError(
String.format("Error thrown when compiling following code\n%s",
source.source));
}
if (dc.diagFound) {
throw new AssertionError(
String.format("Diags found when compiling following code\n%s\n\n%s",
source.source, dc.printDiags()));
}
verifyBytecode();
}
示例8: DocEnv
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
/**
* Constructor
*
* @param context Context for this javadoc instance.
*/
private DocEnv(Context context) {
context.put(docEnvKey, this);
messager = Messager.instance0(context);
syms = Symtab.instance(context);
reader = JavadocClassReader.instance0(context);
enter = JavadocEnter.instance0(context);
names = Names.instance(context);
externalizableSym = reader.enterClass(names.fromString("java.io.Externalizable"));
chk = Check.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
// Default. Should normally be reset with setLocale.
this.doclocale = new DocLocale(this, "", breakiterator);
}
示例9: DocEnv
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
/**
* Constructor
*
* @param context Context for this javadoc instance.
*/
protected DocEnv(Context context) {
context.put(docEnvKey, this);
messager = Messager.instance0(context);
syms = Symtab.instance(context);
reader = JavadocClassReader.instance0(context);
enter = JavadocEnter.instance0(context);
names = Names.instance(context);
externalizableSym = reader.enterClass(names.fromString("java.io.Externalizable"));
chk = Check.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
// Default. Should normally be reset with setLocale.
this.doclocale = new DocLocale(this, "", breakiterator);
}
示例10: TreeScannerStateful
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
public TreeScannerStateful(CompilationTask task, JCCompilationUnit jcc) {
this.jcc = jcc ;
trees = Trees.instance(task);
treesC = (JavacTrees)trees;
//Rabbit hole to Wonderland
context = ((BasicJavacTask)task).getContext() ;
this.task = ((BasicJavacTask)task) ;
//Initialize magical classes !
make = TreeMaker.instance(context) ;
names = Names.instance(context) ;
syms = Symtab.instance(context);
types = Types.instance(context) ;
typesC = JavacTypes.instance(context) ;
attr = Attr.instance(context) ;
enter = Enter.instance(context) ;
resolve = Resolve.instance(context) ;
memberEnter = MemberEnter.instance(context) ;
javacElements = JavacElements.instance(context) ;
info = TreeInfo.instance(context) ;
sourcePositions = trees.getSourcePositions();
elements = ((JavacTask)task).getElements();
elementsC = (JavacElements)elements;
}
示例11: Modules
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
protected Modules(Context context) {
context.put(Modules.class, this);
log = Log.instance(context);
names = Names.instance(context);
syms = Symtab.instance(context);
attr = Attr.instance(context);
chk = Check.instance(context);
deferredLintHandler = DeferredLintHandler.instance(context);
typeEnvs = TypeEnvs.instance(context);
moduleFinder = ModuleFinder.instance(context);
types = Types.instance(context);
fileManager = context.get(JavaFileManager.class);
source = Source.instance(context);
allowModules = source.allowModules();
Options options = Options.instance(context);
allowAccessIntoSystem = options.isUnset(Option.RELEASE);
lintOptions = options.isUnset(Option.XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option);
multiModuleMode = fileManager.hasLocation(StandardLocation.MODULE_SOURCE_PATH);
ClassWriter classWriter = ClassWriter.instance(context);
classWriter.multiModuleMode = multiModuleMode;
JNIWriter jniWriter = JNIWriter.instance(context);
jniWriter.multiModuleMode = multiModuleMode;
java_se = names.fromString("java.se");
java_ = names.fromString("java.");
addExportsOpt = options.get(Option.ADD_EXPORTS);
addReadsOpt = options.get(Option.ADD_READS);
addModsOpt = options.get(Option.ADD_MODULES);
limitModsOpt = options.get(Option.LIMIT_MODULES);
moduleVersionOpt = options.get(Option.MODULE_VERSION);
}
示例12: complete
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
private List<String> complete(Path test, List<Path> order, Path missing, boolean badClassFile) {
Context context = new Context();
if (badClassFile) {
TestClassReader.preRegister(context);
}
JavacTool tool = JavacTool.create();
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, null, null, List.of("-classpath", test.toString(), "-XDblockClass=" + flatName(missing)), null, null, context);
Symtab syms = Symtab.instance(context);
Names names = Names.instance(context);
task.getElements().getTypeElement("java.lang.Object");
if (!badClassFile) {
//to ensure the same paths taken in ClassFinder.completeEnclosing in case the file is missing:
syms.enterClass(syms.unnamedModule, names.fromString(flatName(missing)));
}
List<String> result = new ArrayList<>();
for (Path toCheck : order) {
ClassSymbol sym = syms.enterClass(syms.unnamedModule, names.fromString(flatName(toCheck)));
try {
sym.complete();
} catch (CompletionFailure ignore) {
}
long flags = sym.flags_field;
flags &= ~(Flags.CLASS_SEEN | Flags.SOURCE_SEEN);
result.add("sym: " + sym.flatname + ", " + sym.owner.flatName() +
", " + sym.type + ", " + sym.members_field + ", " + flags);
}
return result;
}
示例13: TreeFactory
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
protected TreeFactory(Context context) {
context.put(contextKey, this);
model = ASTService.instance(context);
names = Names.instance(context);
classReader = ClassReader.instance(context);
make = com.sun.tools.javac.tree.TreeMaker.instance(context);
docMake = com.sun.tools.javac.tree.DocTreeMaker.instance(context);
elements = JavacElements.instance(context);
types = JavacTypes.instance(context);
chs = CommentHandlerService.instance(context);
make.toplevel = null;
}
示例14: ElementsService
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
protected ElementsService(Context context) {
context.put(KEY, this);
jctypes = com.sun.tools.javac.code.Types.instance(context);
names = Names.instance(context);
types = JavacTypes.instance(context);
allowDefaultMethods = SourceLevelUtils.allowDefaultMethods(Source.instance(context));
}
示例15: createPackageElement
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
private PackageElement createPackageElement(AnalyzeTask at, String packageName) {
Names names = Names.instance(at.getContext());
Symtab syms = Symtab.instance(at.getContext());
PackageElement existing = syms.enterPackage(syms.unnamedModule, names.fromString(packageName));
return existing;
}