本文整理汇总了Java中com.sun.tools.javac.code.Symbol.CompletionFailure类的典型用法代码示例。如果您正苦于以下问题:Java CompletionFailure类的具体用法?Java CompletionFailure怎么用?Java CompletionFailure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompletionFailure类属于com.sun.tools.javac.code.Symbol包,在下文中一共展示了CompletionFailure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeElementByBinaryName
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的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: createTaggedController
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
static long createTaggedController(final FileObject fo, int position, final long timestamp, final Object[] controller) throws IOException {
ClasspathInfo cpi = ClasspathInfo.create(fo);
Collection<Source> sources = Collections.singleton(Source.create(fo));
CompilationController cc = (CompilationController) controller[0];
final NewComilerTask _task = new NewComilerTask(cpi, position, cc, timestamp);
try {
ParserManager.parse(sources, _task);
controller[0] = _task.getCompilationController();
return _task.getTimeStamp();
} catch (final ParseException pe) {
final Throwable rootCase = pe.getCause();
if (rootCase instanceof CompletionFailure) {
throw new IOException (rootCase);
} else if (rootCase instanceof RuntimeException) {
throw (RuntimeException) rootCase;
} else {
throw new IOException (rootCase);
}
}
}
示例3: process
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
try {
Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
if (classes.size() > 0) {
checkMethodParameters(classes);
g.setProcessingEnvironment(processingEnv);
g.setClasses(classes);
g.run();
}
} catch (CompletionFailure cf) {
messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
} catch (ClassNotFoundException cnfe) {
messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
} catch (IOException ioe) {
messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
} catch (Util.Exit e) {
exit = e;
}
return true;
}
示例4: make0
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
/**
* Construct a new javadoc tool.
*/
public static JavadocTool make0(Context context) {
Messager messager = null;
try {
// force the use of Javadoc's class reader
JavadocClassReader.preRegister(context);
// force the use of Javadoc's own enter phase
JavadocEnter.preRegister(context);
// force the use of Javadoc's own member enter phase
JavadocMemberEnter.preRegister(context);
// force the use of Javadoc's own todo phase
JavadocTodo.preRegister(context);
// force the use of Messager as a Log
messager = Messager.instance0(context);
return new JavadocTool(context);
} catch (CompletionFailure ex) {
messager.error(Position.NOPOS, ex.getMessage());
return null;
}
}
示例5: process
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
@DefinedBy(Api.ANNOTATION_PROCESSING)
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
try {
Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
if (classes.size() > 0) {
checkMethodParameters(classes);
g.setProcessingEnvironment(processingEnv);
g.setClasses(classes);
g.run();
}
} catch (CompletionFailure cf) {
messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
} catch (ClassNotFoundException cnfe) {
messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
} catch (IOException ioe) {
messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
} catch (Util.Exit e) {
exit = e;
}
return true;
}
示例6: getSymbols
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
@Override
public Iterable<Symbol> getSymbols(final Filter<Symbol> sf, final LookupKind lookupKind) {
if (filterName != null)
return getSymbolsByName(filterName, sf, lookupKind);
try {
SymbolImporter si = new SymbolImporter(imp.staticImport) {
@Override
Iterable<Symbol> doLookup(TypeSymbol tsym) {
return tsym.members().getSymbols(sf, lookupKind);
}
};
List<Iterable<Symbol>> results =
si.importFrom((TypeSymbol) origin.owner, List.nil());
return () -> createFilterIterator(createCompoundIterator(results,
Iterable::iterator),
s -> filter.accepts(origin, s));
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
}
}
示例7: getSymbolsByName
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
@Override
public Iterable<Symbol> getSymbolsByName(final Name name,
final Filter<Symbol> sf,
final LookupKind lookupKind) {
if (filterName != null && filterName != name)
return Collections.emptyList();
try {
SymbolImporter si = new SymbolImporter(imp.staticImport) {
@Override
Iterable<Symbol> doLookup(TypeSymbol tsym) {
return tsym.members().getSymbolsByName(name, sf, lookupKind);
}
};
List<Iterable<Symbol>> results =
si.importFrom((TypeSymbol) origin.owner, List.nil());
return () -> createFilterIterator(createCompoundIterator(results,
Iterable::iterator),
s -> filter.accepts(origin, s));
} catch (CompletionFailure cf) {
cfHandler.accept(imp, cf);
return Collections.emptyList();
}
}
示例8: synthesizeEmptyInterfaceIfMissing
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
public void synthesizeEmptyInterfaceIfMissing(final Type type) {
final Completer completer = type.tsym.completer;
type.tsym.completer = new Completer() {
@Override
public void complete(Symbol sym) throws CompletionFailure {
try {
completer.complete(sym);
} catch (CompletionFailure e) {
sym.flags_field |= (PUBLIC | INTERFACE);
((ClassType) sym.type).supertype_field = objectType;
}
}
@Override
public boolean isTerminal() {
return completer.isTerminal();
}
};
}
示例9: loadClass
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
/** Load a toplevel class with given fully qualified name
* The class is entered into `classes' only if load was successful.
*/
public ClassSymbol loadClass(ModuleSymbol msym, Name flatname) throws CompletionFailure {
Assert.checkNonNull(msym);
Name packageName = Convert.packagePart(flatname);
PackageSymbol ps = syms.lookupPackage(msym, packageName);
Assert.checkNonNull(ps.modle, () -> "msym=" + msym + "; flatName=" + flatname);
boolean absent = syms.getClass(ps.modle, flatname) == null;
ClassSymbol c = syms.enterClass(ps.modle, flatname);
if (c.members_field == null) {
try {
c.complete();
} catch (CompletionFailure ex) {
if (absent) syms.removeClass(ps.modle, flatname);
throw ex;
}
}
return c;
}
示例10: completeAutomaticModule
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
private void completeAutomaticModule(ModuleSymbol msym) throws CompletionFailure {
ListBuffer<Directive> directives = new ListBuffer<>();
directives.addAll(msym.directives);
ListBuffer<RequiresDirective> requires = new ListBuffer<>();
for (ModuleSymbol ms : allModules()) {
if (ms == syms.unnamedModule || ms == msym)
continue;
Set<RequiresFlag> flags = (ms.flags_field & Flags.AUTOMATIC_MODULE) != 0 ?
EnumSet.of(RequiresFlag.TRANSITIVE) : EnumSet.noneOf(RequiresFlag.class);
RequiresDirective d = new RequiresDirective(ms, flags);
directives.add(d);
requires.add(d);
}
RequiresDirective requiresUnnamed = new RequiresDirective(syms.unnamedModule);
directives.add(requiresUnnamed);
requires.add(requiresUnnamed);
msym.requires = requires.toList();
msym.directives = directives.toList();
}
示例11: getUnnamedModuleCompleter
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
private Completer getUnnamedModuleCompleter() {
moduleFinder.findAllModules();
return new Symbol.Completer() {
@Override
public void complete(Symbol sym) throws CompletionFailure {
if (inInitModules) {
sym.completer = this;
return ;
}
ModuleSymbol msym = (ModuleSymbol) sym;
Set<ModuleSymbol> allModules = new HashSet<>(allModules());
allModules.remove(syms.unnamedModule);
for (ModuleSymbol m : allModules) {
m.complete();
}
initVisiblePackages(msym, allModules);
}
@Override
public String toString() {
return "unnamedModule Completer";
}
};
}
示例12: getEnclosedElements
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
private List<? extends Element> getEnclosedElements(PackageElement packageEl) {
if (packageEl == null) {
return Collections.emptyList();
}
//workaround for: JDK-8024687
while (true) {
try {
return packageEl.getEnclosedElements()
.stream()
.filter(el -> el.asType() != null)
.filter(el -> el.asType().getKind() != TypeKind.ERROR)
.collect(toList());
} catch (CompletionFailure cf) {
//ignore...
}
}
}
示例13: make0
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
/**
* Construct a new javadoc tool.
*/
public static JavadocTool make0(Context context) {
Messager messager = null;
try {
// force the use of Javadoc's class finder
JavadocClassFinder.preRegister(context);
// force the use of Javadoc's own enter phase
JavadocEnter.preRegister(context);
// force the use of Javadoc's own member enter phase
JavadocMemberEnter.preRegister(context);
// force the use of Javadoc's own todo phase
JavadocTodo.preRegister(context);
// force the use of Messager as a Log
messager = Messager.instance0(context);
return new JavadocTool(context);
} catch (CompletionFailure ex) {
messager.error(Position.NOPOS, ex.getMessage());
return null;
}
}
示例14: addAllClasses
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
/**
* Adds all inner classes of this class, and their inner classes recursively, to the list
*/
private void addAllClasses(Collection<TypeElement> list, TypeElement typeElement, boolean filtered) {
ClassSymbol klass = (ClassSymbol)typeElement;
try {
// eliminate needless checking, do this first.
if (list.contains(klass)) return;
// ignore classes with invalid Java class names
if (!JavadocTool.isValidClassName(klass.name.toString())) return;
if (filtered && !isTypeElementSelected(klass)) return;
list.add(klass);
for (Symbol sym : klass.members().getSymbols(NON_RECURSIVE)) {
if (sym != null && sym.kind == Kind.TYP) {
ClassSymbol s = (ClassSymbol)sym;
addAllClasses(list, s, filtered);
}
}
} catch (CompletionFailure e) {
if (e.getMessage() != null)
messager.printWarning(e.getMessage());
else
messager.printWarningUsingKey("main.unexpected.exception", e);
}
}
示例15: process
import com.sun.tools.javac.code.Symbol.CompletionFailure; //导入依赖的package包/类
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv) {
try {
processingEnv.getElementUtils().getTypeElement("SuperClass");
} catch (CompletionFailure cf) {
cf.printStackTrace();
}
if (round++ == 1) {
try (Writer out = filer.createSourceFile("SuperClass").openWriter()) {
String code = "class SuperClass { public int get() { return 0; } }";
out.write(code);
out.close();
} catch (IOException e) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, e.toString());
}
}
return false;
}