com.sun.tools.javac.code.Kinds.Kind Java Examples
The following examples show how to use
com.sun.tools.javac.code.Kinds.Kind.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SymbolMetadata.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void setAttributes(SymbolMetadata other) { if (other == null) { throw new NullPointerException(); } setDeclarationAttributes(other.getDeclarationAttributes()); if ((sym.flags() & Flags.BRIDGE) != 0) { Assert.check(other.sym.kind == Kind.MTH); ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>(); for (TypeCompound tc : other.getTypeAttributes()) { // Carry over only contractual type annotations: i.e nothing interior to method body. if (!tc.position.type.isLocal()) typeAttributes.append(tc); } setTypeAttributes(typeAttributes.toList()); } else { setTypeAttributes(other.getTypeAttributes()); } if (sym.kind == Kind.TYP) { setInitTypeAttributes(other.getInitTypeAttributes()); setClassInitTypeAttributes(other.getClassInitTypeAttributes()); } }
Example #2
Source File: Analyzer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
void doAnalysis(RewritingContext rewriting) { DiagnosticSource prevSource = log.currentSource(); LocalCacheContext localCacheContext = argumentAttr.withLocalCacheContext(); try { log.useSource(rewriting.env.toplevel.getSourceFile()); JCStatement treeToAnalyze = (JCStatement)rewriting.originalTree; if (rewriting.env.info.scope.owner.kind == Kind.TYP) { //add a block to hoist potential dangling variable declarations treeToAnalyze = make.Block(Flags.SYNTHETIC, List.of((JCStatement)rewriting.originalTree)); } //TODO: to further refine the analysis, try all rewriting combinations deferredAttr.attribSpeculative(treeToAnalyze, rewriting.env, attr.statInfo, new TreeRewriter(rewriting), t -> rewriting.diagHandler(), argumentAttr.withLocalCacheContext()); rewriting.analyzer.process(rewriting.oldTree, rewriting.replacement, rewriting.erroneous); } catch (Throwable ex) { Assert.error("Analyzer error when processing: " + rewriting.originalTree); } finally { log.useSource(prevSource.getFile()); localCacheContext.leave(); } }
Example #3
Source File: ElementUtils.java From netbeans with Apache License 2.0 | 6 votes |
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); Check chk = Check.instance(ctx); final Name wrappedName = names.fromString(name); ClassSymbol clazz = chk.getCompiled((ModuleSymbol) mod, wrappedName); if (clazz != null) { return clazz; } clazz = syms.enterClass((ModuleSymbol) mod, wrappedName); try { clazz.complete(); if (clazz.kind == Kind.TYP && clazz.flatName() == wrappedName) { return clazz; } } catch (CompletionFailure cf) { } return null; }
Example #4
Source File: SymbolMetadata.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void setAttributes(SymbolMetadata other) { if (other == null) { throw new NullPointerException(); } setDeclarationAttributes(other.getDeclarationAttributes()); if ((sym.flags() & Flags.BRIDGE) != 0) { Assert.check(other.sym.kind == Kind.MTH); ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>(); for (TypeCompound tc : other.getTypeAttributes()) { // Carry over only contractual type annotations: i.e nothing interior to method body. if (!tc.position.type.isLocal()) typeAttributes.append(tc); } setTypeAttributes(typeAttributes.toList()); } else { setTypeAttributes(other.getTypeAttributes()); } if (sym.kind == Kind.TYP) { setInitTypeAttributes(other.getInitTypeAttributes()); setClassInitTypeAttributes(other.getClassInitTypeAttributes()); } }
Example #5
Source File: ElementsTable.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private String getModuleName(Location location) throws ToolException { try { JavaFileObject jfo = fm.getJavaFileForInput(location, "module-info", JavaFileObject.Kind.SOURCE); if (jfo != null) { JCCompilationUnit jcu = compiler.parse(jfo); JCModuleDecl module = TreeInfo.getModule(jcu); if (module != null) { return module.getName().toString(); } } } catch (IOException ioe) { String text = messager.getText("main.file.manager.list", location); throw new ToolException(SYSERR, text, ioe); } return null; }
Example #6
Source File: ElementsTable.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * 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); } }
Example #7
Source File: Symbol.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Construct a symbol with given kind, flags, name, type and owner. */ public Symbol(Kind kind, long flags, Name name, Type type, Symbol owner) { this.kind = kind; this.flags_field = flags; this.type = type; this.owner = owner; this.completer = Completer.NULL_COMPLETER; this.erasure_field = null; this.name = name; }
Example #8
Source File: Symbol.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** Construct a symbol with given kind, flags, name, type and owner. */ public Symbol(Kind kind, long flags, Name name, Type type, Symbol owner) { this.kind = kind; this.flags_field = flags; this.type = type; this.owner = owner; this.completer = Completer.NULL_COMPLETER; this.erasure_field = null; this.name = name; }
Example #9
Source File: NewDependencyCollector.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override @DefinedBy(Api.COMPILER_TREE) public void finished(TaskEvent e) { if (e.getKind() == TaskEvent.Kind.COMPILATION) { collectPubApisOfDependencies(context, explicitJFOs); deps = getDependencies(context, explicitJFOs, false); cpDeps = getDependencies(context, explicitJFOs, true); } }
Example #10
Source File: ElementsTable.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Iterable<JavaFileObject> fmList(Location location, String packagename, Set<JavaFileObject.Kind> kinds, boolean recurse) throws ToolException { try { return fm.list(location, packagename, kinds, recurse); } catch (IOException ioe) { String text = messager.getText("main.file.manager.list", packagename); throw new ToolException(SYSERR, text, ioe); } }
Example #11
Source File: Symbol.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public TypeSymbol(Kind kind, long flags, Name name, Type type, Symbol owner) { super(kind, flags, name, type, owner); }
Example #12
Source File: Analyzer.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
boolean match(JCVariableDecl tree){ return tree.sym.owner.kind == Kind.MTH && tree.init != null && !tree.isImplicitlyTyped() && attr.canInferLocalVarType(tree) == null; }
Example #13
Source File: Symbol.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public TypeSymbol(Kind kind, long flags, Name name, Type type, Symbol owner) { super(kind, flags, name, type, owner); }