本文整理汇总了Java中com.sun.tools.javac.util.Names类的典型用法代码示例。如果您正苦于以下问题:Java Names类的具体用法?Java Names怎么用?Java Names使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Names类属于com.sun.tools.javac.util包,在下文中一共展示了Names类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VeryPretty
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
private VeryPretty(Context context, CodeStyle cs, Map<Tree, ?> tree2Tag, Map<Tree, DocCommentTree> tree2Doc, Map<?, int[]> tag2Span, String origText) {
names = Names.instance(context);
enclClass = null;
commentHandler = CommentHandlerService.instance(context);
operators = Operators.instance(context);
widthEstimator = new WidthEstimator(context);
danglingElseChecker = new DanglingElseChecker();
prec = TreeInfo.notExpression;
this.cs = cs;
out = new CharBuffer(cs.getRightMargin(), cs.getTabSize(), cs.expandTabToSpaces());
out.addTrimObserver(this);
this.indentSize = cs.getIndentSize();
this.tree2Tag = tree2Tag;
this.tree2Doc = tree2Doc == null ? Collections.EMPTY_MAP : tree2Doc;
this.tag2Span = (Map<Object, int[]>) tag2Span;//XXX
this.origText = origText;
this.comments = CommentHandlerService.instance(context);
}
示例2: CasualDiff
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
protected CasualDiff(Context context, DiffContext diffContext, TreeUtilities treeUtilities, Map<Tree, ?> tree2Tag, Map<Tree, DocCommentTree> tree2Doc, Map<?, int[]> tag2Span, Set<Tree> oldTrees) {
diffs = new LinkedHashSet<Diff>();
comments = CommentHandlerService.instance(context);
this.treeUtilities = treeUtilities;
this.diffContext = diffContext;
this.tokenSequence = diffContext.tokenSequence;
this.origText = diffContext.origText;
this.context = context;
this.names = Names.instance(context);
this.tree2Tag = tree2Tag;
this.tree2Doc = tree2Doc;
this.tag2Span = (Map<Object, int[]>) tag2Span;//XXX
printer = new VeryPretty(diffContext, diffContext.style, tree2Tag, tree2Doc, tag2Span, origText);
printer.oldTrees = oldTrees;
this.oldTrees = oldTrees;
}
示例3: getTypeElementByBinaryName
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
public static TypeElement getTypeElementByBinaryName(JavacTask task, ModuleElement mod, String name) {
Context ctx = ((JavacTaskImpl) task).getContext();
Names names = Names.instance(ctx);
Symtab syms = Symtab.instance(ctx);
final Name wrappedName = names.fromString(name);
ClassSymbol clazz = syms.enterClass((ModuleSymbol) mod, wrappedName);
try {
clazz.complete();
if (clazz.kind == Kind.TYP &&
clazz.flatName() == wrappedName) {
return clazz;
}
} catch (CompletionFailure cf) {
}
return null;
}
示例4: NBClassReader
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
public NBClassReader(Context context) {
super(context);
names = Names.instance(context);
nbNames = NBNames.instance(context);
NBAttributeReader[] readers = {
new NBAttributeReader(nbNames._org_netbeans_EnclosingMethod, Version.V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
public void read(Symbol sym, int attrLen) {
int newbp = bp + attrLen;
readEnclosingMethodAttr(sym);
bp = newbp;
}
},
};
for (NBAttributeReader r: readers)
attributeReaders.put(r.getName(), r);
}
示例5: buildReturnCheck
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
@NotNull
private static Optional<List<JCTree.JCStatement>> buildReturnCheck(@NotNull ReturnToInstrumentInfo info) {
CompilationUnitProcessingContext context = info.getContext();
ExpressionTree returnExpression = info.getReturnExpression().getExpression();
if (!(returnExpression instanceof JCTree.JCExpression)) {
context.getLogger().reportDetails(String.format(
"find a 'return' expression of type %s but got %s",
JCTree.JCExpression.class.getName(), returnExpression.getClass().getName()
));
return Optional.empty();
}
JCTree.JCExpression returnJcExpression = (JCTree.JCExpression) returnExpression;
TreeMaker factory = context.getAstFactory();
Names symbolsTable = context.getSymbolsTable();
ExceptionTextGenerator<ReturnToInstrumentInfo> generator =
context.getExceptionTextGeneratorManager().getGenerator(METHOD_RETURN, context.getPluginSettings());
String errorMessage = generator.generate(info);
List<JCTree.JCStatement> result = List.of(
factory.VarDef(
factory.Modifiers(0),
symbolsTable.fromString(info.getTmpVariableName()),
info.getReturnType(),
returnJcExpression
)
);
String exceptionToThrow = info.getContext().getPluginSettings().getExceptionToThrow(METHOD_RETURN);
result = result.append(InstrumentationUtil.buildVarCheck(factory,
symbolsTable,
info.getTmpVariableName(),
errorMessage,
exceptionToThrow));
result = result.append(
factory.Return(
factory.Ident(symbolsTable.fromString(info.getTmpVariableName()))));
return Optional.of(result);
}
示例6: CompilationUnitProcessingContext
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
public CompilationUnitProcessingContext(
@NotNull TrautePluginSettings pluginSettings,
@NotNull TreeMaker astFactory,
@NotNull Names symbolsTable,
@NotNull TrautePluginLogger logger,
@NotNull StatsCollector statsCollector,
@NotNull ExceptionTextGeneratorManager exceptionTextGeneratorManager,
@NotNull PackageInfoManager packageInfoManager)
{
this.pluginSettings = pluginSettings;
this.statsCollector = statsCollector;
this.astFactory = astFactory;
this.symbolsTable = symbolsTable;
this.logger = logger;
this.exceptionTextGeneratorManager = exceptionTextGeneratorManager;
this.packageInfoManager = packageInfoManager;
}
示例7: 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();
}
示例8: Enter
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
protected Enter(Context context) {
context.put(enterKey, this);
log = Log.instance(context);
reader = ClassReader.instance(context);
make = TreeMaker.instance(context);
syms = Symtab.instance(context);
chk = Check.instance(context);
memberEnter = MemberEnter.instance(context);
types = Types.instance(context);
annotate = Annotate.instance(context);
lint = Lint.instance(context);
names = Names.instance(context);
predefClassDef = make.ClassDef(
make.Modifiers(PUBLIC),
syms.predefClass.name, null, null, null, null);
predefClassDef.sym = syms.predefClass;
todo = Todo.instance(context);
fileManager = context.get(JavaFileManager.class);
Options options = Options.instance(context);
pkginfoOpt = PkgInfo.get(options);
}
示例9: findConstructor
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
/**
* Find constructor in this class.
*
* @param constrName the unqualified name to search for.
* @param paramTypes the array of Strings for constructor parameters.
* @return the first ConstructorDocImpl which matches, null if not found.
*/
public ConstructorDoc findConstructor(String constrName,
String[] paramTypes) {
Names names = tsym.name.table.names;
for (Scope.Entry e = tsym.members().lookup(names.fromString("<init>")); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.MTH) {
if (hasParameterTypes((MethodSymbol)e.sym, paramTypes)) {
return env.getConstructorDoc((MethodSymbol)e.sym);
}
}
}
//###(gj) As a temporary measure until type variables are better
//### handled, try again without the parameter types.
//### This will often find the right constructor, and occassionally
//### find the wrong one.
//if (paramTypes != null) {
// return findConstructor(constrName, null);
//}
return null;
}
示例10: getDefinedSerializableFields
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
private VarSymbol getDefinedSerializableFields(ClassSymbol def) {
Names names = def.name.table.names;
/* SERIALIZABLE_FIELDS can be private,
* so must lookup by ClassSymbol, not by ClassDocImpl.
*/
for (Scope.Entry e = def.members().lookup(names.fromString(SERIALIZABLE_FIELDS)); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.VAR) {
VarSymbol f = (VarSymbol)e.sym;
if ((f.flags() & Flags.STATIC) != 0 &&
(f.flags() & Flags.PRIVATE) != 0) {
return f;
}
}
}
return null;
}
示例11: addMethodIfExist
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
private void addMethodIfExist(DocEnv env, ClassSymbol def, String methodName) {
Names names = def.name.table.names;
for (Scope.Entry e = def.members().lookup(names.fromString(methodName)); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.MTH) {
MethodSymbol md = (MethodSymbol)e.sym;
if ((md.flags() & Flags.STATIC) == 0) {
/*
* WARNING: not robust if unqualifiedMethodName is overloaded
* method. Signature checking could make more robust.
* READOBJECT takes a single parameter, java.io.ObjectInputStream.
* WRITEOBJECT takes a single parameter, java.io.ObjectOutputStream.
*/
methods.append(env.getMethodDoc(md));
}
}
}
}
示例12: 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);
}
示例13: 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;
}
示例14: Analyzer
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
protected Analyzer(Context context) {
context.put(analyzerKey, this);
types = Types.instance(context);
log = Log.instance(context);
attr = Attr.instance(context);
deferredAttr = DeferredAttr.instance(context);
argumentAttr = ArgumentAttr.instance(context);
make = TreeMaker.instance(context);
names = Names.instance(context);
Options options = Options.instance(context);
String findOpt = options.get("find");
//parse modes
Source source = Source.instance(context);
allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation();
analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source);
}
示例15: ToolEnvironment
import com.sun.tools.javac.util.Names; //导入依赖的package包/类
/**
* Constructor
*
* @param context Context for this javadoc instance.
*/
protected ToolEnvironment(Context context) {
context.put(ToolEnvKey, 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<>();
}