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

The following examples show how to use com.sun.tools.javac.util.Name#toString() . 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: Dependencies.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the map from class names to their pubapi to a map
 * from package names to their pubapi (which is the sorted concatenation
 * of all the class pubapis)
 */
public Map<String,String> getPubapis() {
    Map<String,String> publicApiPerPackage = new HashMap<String,String>();
    if (publicApiPerClass == null) return publicApiPerPackage;
    Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
    Arrays.sort(keys, new CompareNames());
    StringBuffer newPublicApi = new StringBuffer();
    int i=0;
    String prevPkg = "";
    for (Name k : keys) {
        String cn = k.toString();
        String pn = "";
        int dp = cn.lastIndexOf('.');
        if (dp != -1) {
            pn = cn.substring(0,dp);
        }
        if (!pn.equals(prevPkg)) {
            if (!prevPkg.equals("")) {
                // Add default module name ":"
                publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
            }
            newPublicApi = new StringBuffer();
            prevPkg = pn;
        }
        newPublicApi.append(publicApiPerClass.get(k));
        i++;
    }
    if (!prevPkg.equals(""))
        publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
    return publicApiPerPackage;
}
 
Example 2
Source File: Dependencies.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the map from class names to their pubapi to a map
 * from package names to their pubapi (which is the sorted concatenation
 * of all the class pubapis)
 */
public Map<String,String> getPubapis() {
    Map<String,String> publicApiPerPackage = new HashMap<String,String>();
    if (publicApiPerClass == null) return publicApiPerPackage;
    Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
    Arrays.sort(keys, new CompareNames());
    StringBuffer newPublicApi = new StringBuffer();
    int i=0;
    String prevPkg = "";
    for (Name k : keys) {
        String cn = k.toString();
        String pn = "";
        int dp = cn.lastIndexOf('.');
        if (dp != -1) {
            pn = cn.substring(0,dp);
        }
        if (!pn.equals(prevPkg)) {
            if (!prevPkg.equals("")) {
                // Add default module name ":"
                publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
            }
            newPublicApi = new StringBuffer();
            prevPkg = pn;
        }
        newPublicApi.append(publicApiPerClass.get(k));
        i++;
    }
    if (!prevPkg.equals(""))
        publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
    return publicApiPerPackage;
}
 
Example 3
Source File: PackageDocImpl.java    From openjdk-8 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: Dependencies.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the map from class names to their pubapi to a map
 * from package names to their pubapi (which is the sorted concatenation
 * of all the class pubapis)
 */
public Map<String,String> getPubapis() {
    Map<String,String> publicApiPerPackage = new HashMap<String,String>();
    if (publicApiPerClass == null) return publicApiPerPackage;
    Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
    Arrays.sort(keys, new CompareNames());
    StringBuffer newPublicApi = new StringBuffer();
    int i=0;
    String prevPkg = "";
    for (Name k : keys) {
        String cn = k.toString();
        String pn = "";
        int dp = cn.lastIndexOf('.');
        if (dp != -1) {
            pn = cn.substring(0,dp);
        }
        if (!pn.equals(prevPkg)) {
            if (!prevPkg.equals("")) {
                // Add default module name ":"
                publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
            }
            newPublicApi = new StringBuffer();
            prevPkg = pn;
        }
        newPublicApi.append(publicApiPerClass.get(k));
        i++;
    }
    if (!prevPkg.equals(""))
        publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
    return publicApiPerPackage;
}
 
Example 5
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 6
Source File: Dependencies.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the map from class names to their pubapi to a map
 * from package names to their pubapi (which is the sorted concatenation
 * of all the class pubapis)
 */
public Map<String,String> getPubapis() {
    Map<String,String> publicApiPerPackage = new HashMap<String,String>();
    if (publicApiPerClass == null) return publicApiPerPackage;
    Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
    Arrays.sort(keys, new CompareNames());
    StringBuffer newPublicApi = new StringBuffer();
    int i=0;
    String prevPkg = "";
    for (Name k : keys) {
        String cn = k.toString();
        String pn = "";
        int dp = cn.lastIndexOf('.');
        if (dp != -1) {
            pn = cn.substring(0,dp);
        }
        if (!pn.equals(prevPkg)) {
            if (!prevPkg.equals("")) {
                // Add default module name ":"
                publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
            }
            newPublicApi = new StringBuffer();
            prevPkg = pn;
        }
        newPublicApi.append(publicApiPerClass.get(k));
        i++;
    }
    if (!prevPkg.equals(""))
        publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
    return publicApiPerPackage;
}
 
Example 7
Source File: JavacNode.java    From EasyMPermission with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
@Override public String getName() {
	final Name n;
	
	if (node instanceof JCClassDecl) n = ((JCClassDecl) node).name;
	else if (node instanceof JCMethodDecl) n = ((JCMethodDecl) node).name;
	else if (node instanceof JCVariableDecl) n = ((JCVariableDecl) node).name;
	else n = null;
	
	return n == null ? null : n.toString();
}
 
Example 8
Source File: ExtensionTransformer.java    From manifold with Apache License 2.0 5 votes vote down vote up
private void getTypesToCompile( JCTree.JCAnnotation precompileAnno, Map<String, Set<String>> typeNames )
{
  Attribute.Compound attribute = precompileAnno.attribute;
  if( attribute == null )
  {
    return;
  }

  String typeManifoldClassName = null;
  String regex = ".*";
  String ext = "*";
  for( com.sun.tools.javac.util.Pair<Symbol.MethodSymbol, Attribute> pair: attribute.values )
  {
    Name argName = pair.fst.getSimpleName();
    switch( argName.toString() )
    {
      case "typeManifold":
        typeManifoldClassName = pair.snd.getValue().toString();
        break;
      case "fileExtension":
        ext = pair.snd.getValue().toString();
        break;
      case "typeNames":
        regex = pair.snd.getValue().toString();
        break;
    }
  }

  addToPrecompile( typeNames, typeManifoldClassName, ext, regex );
}
 
Example 9
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 10
Source File: PathAndPackageVerifier.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String next() {
    Name name;
    if (next instanceof JCIdent) {
        name = ((JCIdent) next).name;
        next = null;
    } else {
        JCFieldAccess fa = (JCFieldAccess) next;
        name = fa.name;
        next = fa.selected;
    }
    return name.toString();
}
 
Example 11
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 12
Source File: LambdaToMethod.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @return Method name in a form that can be folded into a
 * component of a synthetic method name
 */
String syntheticMethodNameComponent(Name name) {
    if (name == null) {
        return "null";
    }
    String methodName = name.toString();
    if (methodName.equals("<clinit>")) {
        methodName = "static";
    } else if (methodName.equals("<init>")) {
        methodName = "new";
    }
    return methodName;
}
 
Example 13
Source File: Check.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void checkModuleName (JCModuleDecl tree) {
    Name moduleName = tree.sym.name;
    Assert.checkNonNull(moduleName);
    if (lint.isEnabled(LintCategory.MODULE)) {
        JCExpression qualId = tree.qualId;
        while (qualId != null) {
            Name componentName;
            DiagnosticPosition pos;
            switch (qualId.getTag()) {
                case SELECT:
                    JCFieldAccess selectNode = ((JCFieldAccess) qualId);
                    componentName = selectNode.name;
                    pos = selectNode.pos();
                    qualId = selectNode.selected;
                    break;
                case IDENT:
                    componentName = ((JCIdent) qualId).name;
                    pos = qualId.pos();
                    qualId = null;
                    break;
                default:
                    throw new AssertionError("Unexpected qualified identifier: " + qualId.toString());
            }
            if (componentName != null) {
                String moduleNameComponentString = componentName.toString();
                int nameLength = moduleNameComponentString.length();
                if (nameLength > 0 && Character.isDigit(moduleNameComponentString.charAt(nameLength - 1))) {
                    log.warning(Lint.LintCategory.MODULE, pos, Warnings.PoorChoiceForModuleName(componentName));
                }
            }
        }
    }
}
 
Example 14
Source File: Dependencies.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the map from class names to their pubapi to a map
 * from package names to their pubapi (which is the sorted concatenation
 * of all the class pubapis)
 */
public Map<String,String> getPubapis() {
    Map<String,String> publicApiPerPackage = new HashMap<String,String>();
    if (publicApiPerClass == null) return publicApiPerPackage;
    Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
    Arrays.sort(keys, new CompareNames());
    StringBuffer newPublicApi = new StringBuffer();
    int i=0;
    String prevPkg = "";
    for (Name k : keys) {
        String cn = k.toString();
        String pn = "";
        int dp = cn.lastIndexOf('.');
        if (dp != -1) {
            pn = cn.substring(0,dp);
        }
        if (!pn.equals(prevPkg)) {
            if (!prevPkg.equals("")) {
                // Add default module name ":"
                publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
            }
            newPublicApi = new StringBuffer();
            prevPkg = pn;
        }
        newPublicApi.append(publicApiPerClass.get(k));
        i++;
    }
    if (!prevPkg.equals(""))
        publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
    return publicApiPerPackage;
}
 
Example 15
Source File: PackageDocImpl.java    From openjdk-jdk8u 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 16
Source File: Dependencies.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the map from class names to their pubapi to a map
 * from package names to their pubapi (which is the sorted concatenation
 * of all the class pubapis)
 */
public Map<String,String> getPubapis() {
    Map<String,String> publicApiPerPackage = new HashMap<String,String>();
    if (publicApiPerClass == null) return publicApiPerPackage;
    Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
    Arrays.sort(keys, new CompareNames());
    StringBuffer newPublicApi = new StringBuffer();
    int i=0;
    String prevPkg = "";
    for (Name k : keys) {
        String cn = k.toString();
        String pn = "";
        int dp = cn.lastIndexOf('.');
        if (dp != -1) {
            pn = cn.substring(0,dp);
        }
        if (!pn.equals(prevPkg)) {
            if (!prevPkg.equals("")) {
                // Add default module name ":"
                publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
            }
            newPublicApi = new StringBuffer();
            prevPkg = pn;
        }
        newPublicApi.append(publicApiPerClass.get(k));
        i++;
    }
    if (!prevPkg.equals(""))
        publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
    return publicApiPerPackage;
}
 
Example 17
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 18
Source File: Dependencies.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Convert the map from class names to their pubapi to a map
 * from package names to their pubapi (which is the sorted concatenation
 * of all the class pubapis)
 */
public Map<String,String> getPubapis() {
    Map<String,String> publicApiPerPackage = new HashMap<String,String>();
    if (publicApiPerClass == null) return publicApiPerPackage;
    Name[] keys = publicApiPerClass.keySet().toArray(new Name[0]);
    Arrays.sort(keys, new CompareNames());
    StringBuffer newPublicApi = new StringBuffer();
    int i=0;
    String prevPkg = "";
    for (Name k : keys) {
        String cn = k.toString();
        String pn = "";
        int dp = cn.lastIndexOf('.');
        if (dp != -1) {
            pn = cn.substring(0,dp);
        }
        if (!pn.equals(prevPkg)) {
            if (!prevPkg.equals("")) {
                // Add default module name ":"
                publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
            }
            newPublicApi = new StringBuffer();
            prevPkg = pn;
        }
        newPublicApi.append(publicApiPerClass.get(k));
        i++;
    }
    if (!prevPkg.equals(""))
        publicApiPerPackage.put(":"+prevPkg, newPublicApi.toString());
    return publicApiPerPackage;
}
 
Example 19
Source File: PackageDocImpl.java    From TencentKona-8 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 20
Source File: GenerateGetMethodProcessor.java    From java-master with Apache License 2.0 4 votes vote down vote up
private Name getNewMethodName(Name name) {
    String s = name.toString();
    return names.fromString("get" + s.substring(0, 1).toUpperCase() + s.substring(1, name.length()));
}