Example usage for org.eclipse.jdt.internal.compiler.util SuffixConstants EXTENSION_java

List of usage examples for org.eclipse.jdt.internal.compiler.util SuffixConstants EXTENSION_java

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.util SuffixConstants EXTENSION_java.

Prototype

String EXTENSION_java

To view the source code for org.eclipse.jdt.internal.compiler.util SuffixConstants EXTENSION_java.

Click Source Link

Usage

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

License:Open Source License

/** Returns the registered Java like extensions. */
public static char[][] getJavaLikeExtensions() {
    if (JAVA_LIKE_EXTENSIONS == null) {
        HashSet<String> fileExtensions = new HashSet<String>();
        fileExtensions.add(SuffixConstants.EXTENSION_java);

        int length = fileExtensions.size();
        // note that file extensions contains "java" as it is defined in JDT Core's plugin.xml
        char[][] extensions = new char[length][];
        extensions[0] = SuffixConstants.EXTENSION_java.toCharArray(); // ensure that "java" is first
        int index = 1;
        Iterator<String> iterator = fileExtensions.iterator();
        while (iterator.hasNext()) {
            String fileExtension = iterator.next();
            if (SuffixConstants.EXTENSION_java.equals(fileExtension))
                continue;
            extensions[index++] = fileExtension.toCharArray();
        }/*  w w w. ja  v a  2  s .  c  o m*/
        JAVA_LIKE_EXTENSIONS = extensions;
    }
    return JAVA_LIKE_EXTENSIONS;
}

From source file:name.webdizz.styler.Util.java

License:Open Source License

public static int indexOfJavaLikeExtension(String fileName) {
    int fileNameLength = fileName.length();

    // Hot-fix by webdizz as we only interesting in .java files
    // char[][] javaLikeExtensions = getJavaLikeExtensions();
    char[][] javaLikeExtensions = new char[1][];
    javaLikeExtensions[0] = SuffixConstants.EXTENSION_java.toCharArray();
    // end of hot-fix

    extensions: for (int i = 0, length = javaLikeExtensions.length; i < length; i++) {
        char[] extension = javaLikeExtensions[i];
        int extensionLength = extension.length;
        int extensionStart = fileNameLength - extensionLength;
        int dotIndex = extensionStart - 1;
        if (dotIndex < 0)
            continue;
        if (fileName.charAt(dotIndex) != '.')
            continue;
        for (int j = 0; j < extensionLength; j++) {
            if (fileName.charAt(extensionStart + j) != extension[j])
                continue extensions;
        }//from ww  w. j  a  v a 2  s .  co m
        return dotIndex;
    }
    return -1;
}

From source file:name.webdizz.styler.Util.java

License:Open Source License

/**
 * Returns the registered Java like extensions.
 *//*from   w  w  w  . j a  v a 2s .com*/
public static char[][] getJavaLikeExtensions() {
    if (JAVA_LIKE_EXTENSIONS == null) {
        char[][] extensions = new char[1][];
        extensions[0] = SuffixConstants.EXTENSION_java.toCharArray();
        JAVA_LIKE_EXTENSIONS = extensions;
    }
    return JAVA_LIKE_EXTENSIONS;
}