Example usage for org.eclipse.jdt.core Signature getSimpleNames

List of usage examples for org.eclipse.jdt.core Signature getSimpleNames

Introduction

In this page you can find the example usage for org.eclipse.jdt.core Signature getSimpleNames.

Prototype

public static String[] getSimpleNames(String name) 

Source Link

Document

Returns all segments of the given dot-separated qualified name.

Usage

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

License:Open Source License

/** Returns a trimmed version the simples names returned by Signature. */
public static String[] getTrimmedSimpleNames(String name) {
    String[] result = Signature.getSimpleNames(name);
    for (int i = 0, length = result.length; i < length; i++) {
        result[i] = result[i].trim();//from  w ww  .j  a  v a  2  s  .  co m
    }
    return result;
}

From source file:com.google.gwt.eclipse.core.search.JavaRefIndex.java

License:Open Source License

/**
 * Returns all classes referenced by this Java ref. This includes the specific
 * type specified in the reference, as well as all declaring types. For
 * example, if the ref's className() is 'com.google.A.B.C', this will return
 * the array: [ com.google.A.B.C, com.google.A.B, com.google.A ]
 *///w  ww .  j  a  v  a  2s. co m
private String[] getClassNames(IIndexedJavaRef ref) {
    String innermostClassName = ref.className().replace('$', '.');
    List<String> segments = Arrays.asList(Signature.getSimpleNames(innermostClassName));
    List<String> classNames = new ArrayList<String>();

    // Build the list of class names from innermost to outermost
    for (int i = segments.size() - 1; i >= 0; i--) {
        // If we hit a lower-case segment, assume it's a package fragment, which
        // means there are no remaining outer types to add to the index
        if (Character.isLowerCase(segments.get(i).charAt(0))) {
            break;
        }

        // Add the current class name (fully-qualified) to the list
        String[] classSegments = segments.subList(0, i + 1).toArray(new String[0]);
        String className = Signature.toQualifiedName(classSegments);
        classNames.add(className);
    }

    return classNames.toArray(new String[0]);
}