Example usage for org.eclipse.jdt.internal.core.util Util toCharArrays

List of usage examples for org.eclipse.jdt.internal.core.util Util toCharArrays

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Util toCharArrays.

Prototype

public static char[][] toCharArrays(String[] a) 

Source Link

Document

Converts a String[] to char[][].

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.BinaryTypeConverter.java

License:Open Source License

/**
 * Convert a binary type into an AST type declaration and put it in the given compilation unit.
 *//*w ww .j a va2 s  . co  m*/
public TypeDeclaration buildTypeDeclaration(IType type, CompilationUnitDeclaration compilationUnit)
        throws JavaModelException {
    PackageFragment pkg = (PackageFragment) type.getPackageFragment();
    char[][] packageName = Util.toCharArrays(pkg.names);

    if (packageName.length > 0) {
        compilationUnit.currentPackage = new ImportReference(packageName, new long[] { 0 }, false,
                ClassFileConstants.AccDefault);
    }

    /* convert type */
    TypeDeclaration typeDeclaration = convert(type, null, null);

    IType alreadyComputedMember = type;
    IType parent = type.getDeclaringType();
    TypeDeclaration previousDeclaration = typeDeclaration;
    while (parent != null) {
        TypeDeclaration declaration = convert(parent, alreadyComputedMember, previousDeclaration);

        alreadyComputedMember = parent;
        previousDeclaration = declaration;
        parent = parent.getDeclaringType();
    }

    compilationUnit.types = new TypeDeclaration[] { previousDeclaration };

    return typeDeclaration;
}

From source file:org.eclipse.jdt.internal.core.CompilationUnit.java

License:Open Source License

/**
 * @see org.eclipse.jdt.internal.compiler.env.ICompilationUnit#getPackageName()
 *///  w w  w.  ja va  2s  .c  om
public char[][] getPackageName() {
    PackageFragment packageFragment = (PackageFragment) getParent();
    if (packageFragment == null)
        return CharOperation.NO_CHAR_CHAR;
    return Util.toCharArrays(packageFragment.names);
}