Java Code Examples for com.sun.tools.javac.util.Name#equals()
The following examples show how to use
com.sun.tools.javac.util.Name#equals() .
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: JavacElements.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 2
Source File: JavacElements.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 3
Source File: JavacElements.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 4
Source File: JavacElements.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 5
Source File: JavacElements.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 6
Source File: JavacElements.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 7
Source File: JavacElements.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns a symbol given the type's or package's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(ModuleSymbol module, String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.getClass(module, name) : syms.lookupPackage(module, name); try { if (sym == null) sym = javaCompiler.resolveIdent(module, nameStr); sym.complete(); return (sym.kind != ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 8
Source File: JavacElements.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 9
Source File: JavacElements.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 10
Source File: JavacElements.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns a symbol given the type's or packages's canonical name, * or null if the name isn't found. */ private <S extends Symbol> S nameToSymbol(String nameStr, Class<S> clazz) { Name name = names.fromString(nameStr); // First check cache. Symbol sym = (clazz == ClassSymbol.class) ? syms.classes.get(name) : syms.packages.get(name); try { if (sym == null) sym = javaCompiler.resolveIdent(nameStr); sym.complete(); return (sym.kind != Kinds.ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) ? clazz.cast(sym) : null; } catch (CompletionFailure e) { return null; } }
Example 11
Source File: HandleBuilder.java From EasyMPermission with MIT License | 5 votes |
public void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) { int len = builderFields.size(); java.util.List<JavacNode> existing = new ArrayList<JavacNode>(); for (JavacNode child : builderType.down()) { if (child.getKind() == Kind.FIELD) existing.add(child); } top: for (int i = len - 1; i >= 0; i--) { BuilderFieldData bfd = builderFields.get(i); if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { bfd.createdFields.addAll(bfd.singularData.getSingularizer().generateFields(bfd.singularData, builderType, source)); } else { for (JavacNode exists : existing) { Name n = ((JCVariableDecl) exists.get()).name; if (n.equals(bfd.name)) { bfd.createdFields.add(exists); continue top; } } JavacTreeMaker maker = builderType.getTreeMaker(); JCModifiers mods = maker.Modifiers(Flags.PRIVATE); JCVariableDecl newField = maker.VarDef(mods, bfd.name, cloneType(maker, bfd.type, source, builderType.getContext()), null); bfd.createdFields.add(injectFieldAndMarkGenerated(builderType, newField)); } } }
Example 12
Source File: Dependencies.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Collect a dependency. curr_pkg is marked as depending on dep_pkg. */ public void collect(Name currPkg, Name depPkg) { if (!currPkg.equals(depPkg)) { Set<Name> theset = deps.get(currPkg); if (theset==null) { theset = new HashSet<Name>(); deps.put(currPkg, theset); } theset.add(depPkg); } }
Example 13
Source File: Dependencies.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Collect a dependency. curr_pkg is marked as depending on dep_pkg. */ public void collect(Name currPkg, Name depPkg) { if (!currPkg.equals(depPkg)) { Set<Name> theset = deps.get(currPkg); if (theset==null) { theset = new HashSet<Name>(); deps.put(currPkg, theset); } theset.add(depPkg); } }
Example 14
Source File: HandleBuilder.java From EasyMPermission with MIT License | 5 votes |
private void makeSimpleSetterMethodForBuilder(JavacNode builderType, JavacNode fieldNode, JavacNode source, boolean fluent, boolean chain) { Name fieldName = ((JCVariableDecl) fieldNode.get()).name; for (JavacNode child : builderType.down()) { if (child.getKind() != Kind.METHOD) continue; Name existingName = ((JCMethodDecl) child.get()).name; if (existingName.equals(fieldName)) return; } String setterName = fluent ? fieldNode.getName() : HandlerUtil.buildAccessorName("set", fieldNode.getName()); JavacTreeMaker maker = fieldNode.getTreeMaker(); JCMethodDecl newMethod = HandleSetter.createSetter(Flags.PUBLIC, fieldNode, maker, setterName, chain, source, List.<JCAnnotation>nil(), List.<JCAnnotation>nil()); injectMethod(builderType, newMethod); }
Example 15
Source File: AnnotationProxyMaker.java From javaide with GNU General Public License v3.0 | 5 votes |
public void visitArray(Attribute.Array a) { Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName(); if (elemName.equals(elemName.table.names.java_lang_Class)) { // Class[] // Construct a proxy for a MirroredTypesException ListBuffer<TypeMirror> elems = new ListBuffer<TypeMirror>(); for (Attribute value : a.values) { Type elem = ((Attribute.Class) value).type; elems.append(elem); } value = new MirroredTypesExceptionProxy(elems.toList()); } else { int len = a.values.length; Class<?> returnClassSaved = returnClass; returnClass = returnClass.getComponentType(); try { Object res = Array.newInstance(returnClass, len); for (int i = 0; i < len; i++) { a.values[i].accept(this); if (value == null || value instanceof ExceptionProxy) { return; } try { Array.set(res, i, value); } catch (IllegalArgumentException e) { value = null; // indicates a type mismatch return; } } value = res; } finally { returnClass = returnClassSaved; } } }
Example 16
Source File: AnnotationProxyMaker.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void visitArray(Attribute.Array a) { Name elemName = ((ArrayType) a.type).elemtype.tsym.getQualifiedName(); if (elemName.equals(elemName.table.names.java_lang_Class)) { // Class[] // Construct a proxy for a MirroredTypesException ListBuffer<TypeMirror> elems = new ListBuffer<>(); for (Attribute value : a.values) { Type elem = ((Attribute.Class) value).classType; elems.append(elem); } value = new MirroredTypesExceptionProxy(elems.toList()); } else { int len = a.values.length; Class<?> returnClassSaved = returnClass; returnClass = returnClass.getComponentType(); try { Object res = Array.newInstance(returnClass, len); for (int i = 0; i < len; i++) { a.values[i].accept(this); if (value == null || value instanceof ExceptionProxy) { return; } try { Array.set(res, i, value); } catch (IllegalArgumentException e) { value = null; // indicates a type mismatch return; } } value = res; } finally { returnClass = returnClassSaved; } } }
Example 17
Source File: Dependencies.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Collect a dependency. curr_pkg is marked as depending on dep_pkg. */ public void collect(Name currPkg, Name depPkg) { if (!currPkg.equals(depPkg)) { Set<Name> theset = deps.get(currPkg); if (theset==null) { theset = new HashSet<Name>(); deps.put(currPkg, theset); } theset.add(depPkg); } }
Example 18
Source File: Dependencies.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Collect a dependency. curr_pkg is marked as depending on dep_pkg. */ public void collect(Name currPkg, Name depPkg) { if (!currPkg.equals(depPkg)) { Set<Name> theset = deps.get(currPkg); if (theset==null) { theset = new HashSet<Name>(); deps.put(currPkg, theset); } theset.add(depPkg); } }
Example 19
Source File: AnnotationProxyMaker.java From Mindustry with GNU General Public License v3.0 | 4 votes |
public void visitArray(Array var1){ Name var2 = ((ArrayType)var1.type).elemtype.tsym.getQualifiedName(); int var6; if(var2.equals(var2.table.names.java_lang_Class)){ ListBuffer var14 = new ListBuffer(); Attribute[] var15 = var1.values; int var16 = var15.length; for(var6 = 0; var6 < var16; ++var6){ Attribute var7 = var15[var6]; Type var8 = var7 instanceof UnresolvedClass ? ((UnresolvedClass)var7).classType : ((com.sun.tools.javac.code.Attribute.Class)var7).classType; var14.append(var8); } this.value = mirrorProxy(var14.toList()); }else{ int var3 = var1.values.length; Class var4 = this.returnClass; this.returnClass = this.returnClass.getComponentType(); try{ Object var5 = java.lang.reflect.Array.newInstance(this.returnClass, var3); for(var6 = 0; var6 < var3; ++var6){ var1.values[var6].accept(this); if(this.value == null || this.value instanceof ExceptionProxy){ return; } try{ java.lang.reflect.Array.set(var5, var6, this.value); }catch(IllegalArgumentException var12){ this.value = null; return; } } this.value = var5; }finally{ this.returnClass = var4; } } }
Example 20
Source File: JavacSingularsRecipes.java From EasyMPermission with MIT License | 4 votes |
public java.util.List<Name> listMethodsToBeGenerated(SingularData data, JavacNode builderType) { Name p = data.pluralName; Name s = data.singularName; if (p.equals(s)) return Collections.singletonList(p); return Arrays.asList(p, s); }