本文整理汇总了Java中com.sun.tools.javac.util.Names.fromString方法的典型用法代码示例。如果您正苦于以下问题:Java Names.fromString方法的具体用法?Java Names.fromString怎么用?Java Names.fromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.util.Names
的用法示例。
在下文中一共展示了Names.fromString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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();
}
示例3: testConvertNameCandidates
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
@Test
public void testConvertNameCandidates(Path base) throws Exception {
Context ctx = new Context();
Names names = Names.instance(ctx);
Name name = names.fromString("com.sun.tools.javac.Attr.BreakAttr");
com.sun.tools.javac.util.List<String> actual =
Convert.classCandidates(name).map(n -> n.toString());
List<String> expected = Arrays.asList(
"com.sun$tools$javac$Attr$BreakAttr",
"com.sun.tools$javac$Attr$BreakAttr",
"com.sun.tools.javac$Attr$BreakAttr",
"com.sun.tools.javac.Attr$BreakAttr",
"com.sun.tools.javac.Attr.BreakAttr"
);
if (!expected.equals(actual)) {
throw new Exception("Expected names not generated: " + actual);
}
}
示例4: mapSerialFieldTagImplsToFieldDocImpls
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
private void mapSerialFieldTagImplsToFieldDocImpls(FieldDocImpl spfDoc,
DocEnv env,
ClassSymbol def) {
Names names = def.name.table.names;
SerialFieldTag[] sfTag = spfDoc.serialFieldTags();
for (int i = 0; i < sfTag.length; i++) {
Name fieldName = names.fromString(sfTag[i].fieldName());
// Look for a FieldDocImpl that is documented by serialFieldTagImpl.
for (Scope.Entry e = def.members().lookup(fieldName); e.scope != null; e = e.next()) {
if (e.sym.kind == Kinds.VAR) {
VarSymbol f = (VarSymbol)e.sym;
FieldDocImpl fdi = env.getFieldDoc(f);
((SerialFieldTagImpl)(sfTag[i])).mapToFieldDocImpl(fdi);
break;
}
}
}
}
示例5: JackpotJavacParser
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
public JackpotJavacParser(Context ctx, NBParserFactory fac,
Lexer S,
boolean keepDocComments,
boolean keepLineMap,
CancelService cancelService,
Names names) {
super(fac, S, keepDocComments, keepLineMap, true, false, cancelService);
this.ctx = ctx;
this.dollar = names.fromString("$");
}
示例6: NBNames
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
protected NBNames(Context context) {
Names n = Names.instance(context);
_org_netbeans_EnclosingMethod = n.fromString("org.netbeans.EnclosingMethod");
_org_netbeans_TypeSignature = n.fromString("org.netbeans.TypeSignature");
_org_netbeans_ParameterNames = n.fromString("org.netbeans.ParameterNames");
_org_netbeans_SourceLevelAnnotations = n.fromString("org.netbeans.SourceLevelAnnotations");
_org_netbeans_SourceLevelParameterAnnotations = n.fromString("org.netbeans.SourceLevelParameterAnnotations");
_org_netbeans_SourceLevelTypeAnnotations = n.fromString("org.netbeans.SourceLevelTypeAnnotations");
}
示例7: getPubApi
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
public PubApi getPubApi(String fullyQualifiedClassName) {
Symtab syms = Symtab.instance(context);
ClassFinder cr = ClassFinder.instance(context);
Names ns = Names.instance(context);
Name n = ns.fromString(fullyQualifiedClassName);
ClassSymbol cs = cr.loadClass(syms.inferModule(Convert.packagePart(n)), n);
PubapiVisitor v = new PubapiVisitor();
v.visit(cs);
return v.getCollectedPubApi();
}
示例8: EnclosingInstanceSymbol
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
public EnclosingInstanceSymbol(Names names, Symbol curr) {
super(
Flags.SYNTHETIC,
names.fromString(GuardedByExpression.ENCLOSING_INSTANCE_NAME),
curr.type,
curr);
}
示例9: run
import com.sun.tools.javac.util.Names; //导入方法依赖的package包/类
void run() {
Context ctx = new Context();
Names names = Names.instance(ctx);
Symbol root = new PackageSymbol(names.empty, null);
Name one = names.fromString("1");
PackageSymbol sym1 = new PackageSymbol(one, new PackageSymbol(names.fromString("a"), root));
PackageSymbol sym2 = new PackageSymbol(one, new PackageSymbol(names.fromString("b"), root));
PackageSymbol sym3 = new PackageSymbol(one, new PackageSymbol(names.fromString("c"), root));
List<Symbol> symbols = Arrays.asList(sym1, sym2, sym3);
List<Function<Scope, Iterable<Symbol>>> getters = Arrays.asList(
scope -> scope.getSymbols(),
scope -> scope.getSymbolsByName(one)
);
for (Function<Scope, Iterable<Symbol>> scope2Content : getters) {
for (int removeAt : new int[] {0, 1, 2, 3}) {
for (Symbol removeWhat : new Symbol[] {sym1, sym2, sym3}) {
WriteableScope s = WriteableScope.create(root);
symbols.forEach(s :: enter);
Iterator<Symbol> it = scope2Content.apply(s).iterator();
List<PackageSymbol> actual = new ArrayList<>();
int count = 0;
while (true) {
if (count++ == removeAt)
s.remove(removeWhat);
if (!it.hasNext())
break;
actual.add((PackageSymbol) it.next());
}
List<Symbol> copy = new ArrayList<>(symbols);
Collections.reverse(copy);
count = 0;
while (true) {
if (count == removeAt && copy.indexOf(removeWhat) >= count)
copy.remove(removeWhat);
count++;
if (count >= copy.size())
break;
}
if (!copy.equals(actual)) {
throw new AssertionError("differs: actual: " + actual + "; expected: " + copy);
}
}
}
}
}