Java Code Examples for com.sun.tools.javac.util.Name#isEmpty()

The following examples show how to use com.sun.tools.javac.util.Name#isEmpty() . 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: Symtab.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ModuleSymbol inferModule(Name packageName) {
    if (packageName.isEmpty())
        return java_base == noModule ? noModule : unnamedModule;//!

    ModuleSymbol msym = null;
    Map<ModuleSymbol,PackageSymbol> map = packages.get(packageName);
    if (map == null)
        return null;
    for (Map.Entry<ModuleSymbol,PackageSymbol> e: map.entrySet()) {
        if (!e.getValue().members().isEmpty()) {
            if (msym == null) {
                msym = e.getKey();
            } else {
                return null;
            }
        }
    }
    return msym;
}
 
Example 2
Source File: Symtab.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public ModuleSymbol inferModule(Name packageName) {
    if (packageName.isEmpty())
        return java_base == noModule ? noModule : unnamedModule;//!

    ModuleSymbol msym = null;
    Map<ModuleSymbol,PackageSymbol> map = packages.get(packageName);
    if (map == null)
        return null;
    for (Map.Entry<ModuleSymbol,PackageSymbol> e: map.entrySet()) {
        if (!e.getValue().members().isEmpty()) {
            if (msym == null) {
                msym = e.getKey();
            } else {
                return null;
            }
        }
    }
    return msym;
}
 
Example 3
Source File: PackageDocImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get package name.
 */
public String qualifiedName() {
    if (qualifiedName == null) {
        Name fullname = sym.getQualifiedName();
        // Some bogus tests depend on the interned "" being returned.
        // See 6457276.
        qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
    }
    return qualifiedName;
}
 
Example 4
Source File: PackageDocImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get package name.
 */
public String qualifiedName() {
    if (qualifiedName == null) {
        Name fullname = sym.getQualifiedName();
        // Some bogus tests depend on the interned "" being returned.
        // See 6457276.
        qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
    }
    return qualifiedName;
}
 
Example 5
Source File: PackageDocImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get package name.
 */
public String qualifiedName() {
    if (qualifiedName == null) {
        Name fullname = sym.getQualifiedName();
        // Some bogus tests depend on the interned "" being returned.
        // See 6457276.
        qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
    }
    return qualifiedName;
}
 
Example 6
Source File: Symbol.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size())
            paramNames = List.nil();
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 7
Source File: Symtab.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public List<ModuleSymbol> listPackageModules(Name packageName) {
    if (packageName.isEmpty())
        return List.nil();

    List<ModuleSymbol> result = List.nil();
    Map<ModuleSymbol,PackageSymbol> map = packages.get(packageName);
    if (map != null) {
        for (Map.Entry<ModuleSymbol, PackageSymbol> e: map.entrySet()) {
            if (!e.getValue().members().isEmpty()) {
                result = result.prepend(e.getKey());
            }
        }
    }
    return result;
}
 
Example 8
Source File: Symtab.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public List<ModuleSymbol> listPackageModules(Name packageName) {
    if (packageName.isEmpty())
        return List.nil();

    List<ModuleSymbol> result = List.nil();
    Map<ModuleSymbol,PackageSymbol> map = packages.get(packageName);
    if (map != null) {
        for (Map.Entry<ModuleSymbol, PackageSymbol> e: map.entrySet()) {
            if (!e.getValue().members().isEmpty()) {
                result = result.prepend(e.getKey());
            }
        }
    }
    return result;
}
 
Example 9
Source File: PackageDocImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get package name.
 */
public String qualifiedName() {
    if (qualifiedName == null) {
        Name fullname = sym.getQualifiedName();
        // Some bogus tests depend on the interned "" being returned.
        // See 6457276.
        qualifiedName = fullname.isEmpty() ? "" : fullname.toString();
    }
    return qualifiedName;
}
 
Example 10
Source File: Symbol.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size())
            paramNames = List.nil();
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 11
Source File: Symbol.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 12
Source File: Symbol.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 13
Source File: Symtab.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public PackageSymbol lookupPackage(ModuleSymbol msym, Name flatName) {
    Assert.checkNonNull(msym);

    if (flatName.isEmpty()) {
        //unnamed packages only from the current module - visiblePackages contains *root* package, not unnamed package!
        return msym.unnamedPackage;
    }

    if (msym == noModule) {
        return enterPackage(msym, flatName);
    }

    msym.complete();

    PackageSymbol pack;

    pack = msym.visiblePackages.get(flatName);

    if (pack != null)
        return pack;

    pack = getPackage(msym, flatName);

    if (pack != null && pack.exists())
        return pack;

    boolean dependsOnUnnamed = msym.requires != null &&
                               msym.requires.stream()
                                            .map(rd -> rd.module)
                                            .anyMatch(mod -> mod == unnamedModule);

    if (dependsOnUnnamed) {
        //msyms depends on the unnamed module, for which we generally don't know
        //the list of packages it "exports" ahead of time. So try to lookup the package in the
        //current module, and in the unnamed module and see if it exists in one of them
        PackageSymbol unnamedPack = getPackage(unnamedModule, flatName);

        if (unnamedPack != null && unnamedPack.exists()) {
            msym.visiblePackages.put(unnamedPack.fullname, unnamedPack);
            return unnamedPack;
        }

        pack = enterPackage(msym, flatName);
        pack.complete();
        if (pack.exists())
            return pack;

        unnamedPack = enterPackage(unnamedModule, flatName);
        unnamedPack.complete();
        if (unnamedPack.exists()) {
            msym.visiblePackages.put(unnamedPack.fullname, unnamedPack);
            return unnamedPack;
        }

        return pack;
    }

    return enterPackage(msym, flatName);
}
 
Example 14
Source File: Symbol.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 15
Source File: Symbol.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 16
Source File: Symtab.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public PackageSymbol lookupPackage(ModuleSymbol msym, Name flatName) {
    Assert.checkNonNull(msym);

    if (flatName.isEmpty()) {
        //unnamed packages only from the current module - visiblePackages contains *root* package, not unnamed package!
        return msym.unnamedPackage;
    }

    if (msym == noModule) {
        return enterPackage(msym, flatName);
    }

    msym.complete();

    PackageSymbol pack;

    pack = msym.visiblePackages.get(flatName);

    if (pack != null)
        return pack;

    pack = getPackage(msym, flatName);

    if (pack != null && pack.exists())
        return pack;

    boolean dependsOnUnnamed = msym.requires != null &&
                               StreamSupport.stream(msym.requires)
                                            .map(rd -> rd.module)
                                            .anyMatch(mod -> mod == unnamedModule);

    if (dependsOnUnnamed) {
        //msyms depends on the unnamed module, for which we generally don't know
        //the list of packages it "exports" ahead of time. So try to lookup the package in the
        //current module, and in the unnamed module and see if it exists in one of them
        PackageSymbol unnamedPack = getPackage(unnamedModule, flatName);

        if (unnamedPack != null && unnamedPack.exists()) {
            msym.visiblePackages.put(unnamedPack.fullname, unnamedPack);
            return unnamedPack;
        }

        pack = enterPackage(msym, flatName);
        pack.complete();
        if (pack.exists())
            return pack;

        unnamedPack = enterPackage(unnamedModule, flatName);
        unnamedPack.complete();
        if (unnamedPack.exists()) {
            msym.visiblePackages.put(unnamedPack.fullname, unnamedPack);
            return unnamedPack;
        }

        return pack;
    }

    return enterPackage(msym, flatName);
}
 
Example 17
Source File: Symbol.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 18
Source File: Symbol.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 19
Source File: Symbol.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}
 
Example 20
Source File: Symbol.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public List<VarSymbol> params() {
    owner.complete();
    if (params == null) {
        // If ClassReader.saveParameterNames has been set true, then
        // savedParameterNames will be set to a list of names that
        // matches the types in type.getParameterTypes().  If any names
        // were not found in the class file, those names in the list will
        // be set to the empty name.
        // If ClassReader.saveParameterNames has been set false, then
        // savedParameterNames will be null.
        List<Name> paramNames = savedParameterNames;
        savedParameterNames = null;
        // discard the provided names if the list of names is the wrong size.
        if (paramNames == null || paramNames.size() != type.getParameterTypes().size()) {
            paramNames = List.nil();
        }
        ListBuffer<VarSymbol> buf = new ListBuffer<VarSymbol>();
        List<Name> remaining = paramNames;
        // assert: remaining and paramNames are both empty or both
        // have same cardinality as type.getParameterTypes()
        int i = 0;
        for (Type t : type.getParameterTypes()) {
            Name paramName;
            if (remaining.isEmpty()) {
                // no names for any parameters available
                paramName = createArgName(i, paramNames);
            } else {
                paramName = remaining.head;
                remaining = remaining.tail;
                if (paramName.isEmpty()) {
                    // no name for this specific parameter
                    paramName = createArgName(i, paramNames);
                }
            }
            buf.append(new VarSymbol(PARAMETER, paramName, t, this));
            i++;
        }
        params = buf.toList();
    }
    return params;
}