Example usage for org.eclipse.jdt.internal.core ClasspathEntry TAG_NON_ACCESSIBLE

List of usage examples for org.eclipse.jdt.internal.core ClasspathEntry TAG_NON_ACCESSIBLE

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core ClasspathEntry TAG_NON_ACCESSIBLE.

Prototype

String TAG_NON_ACCESSIBLE

To view the source code for org.eclipse.jdt.internal.core ClasspathEntry TAG_NON_ACCESSIBLE.

Click Source Link

Usage

From source file:io.sarl.eclipse.util.JavaClasspathParser.java

License:Apache License

@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:innerassignment" })
private static IAccessRule[] decodeAccessRules(NodeList list) {
    if (list == null) {
        return null;
    }/*  w ww .ja  va2 s .c  om*/
    final int length = list.getLength();
    if (length == 0) {
        return null;
    }
    IAccessRule[] result = new IAccessRule[length];
    int index = 0;
    for (int i = 0; i < length; i++) {
        final Node accessRule = list.item(i);
        if (accessRule.getNodeType() == Node.ELEMENT_NODE) {
            final Element elementAccessRule = (Element) accessRule;
            final String pattern = elementAccessRule.getAttribute(ClasspathEntry.TAG_PATTERN);
            if (pattern == null) {
                continue;
            }
            final String tagKind = elementAccessRule.getAttribute(ClasspathEntry.TAG_KIND);
            final int kind;
            if (ClasspathEntry.TAG_ACCESSIBLE.equals(tagKind)) {
                kind = IAccessRule.K_ACCESSIBLE;
            } else if (ClasspathEntry.TAG_NON_ACCESSIBLE.equals(tagKind)) {
                kind = IAccessRule.K_NON_ACCESSIBLE;
            } else if (ClasspathEntry.TAG_DISCOURAGED.equals(tagKind)) {
                kind = IAccessRule.K_DISCOURAGED;
            } else {
                continue;
            }
            final boolean ignoreIfBetter = "true" //$NON-NLS-1$
                    .equals(elementAccessRule.getAttribute(ClasspathEntry.TAG_IGNORE_IF_BETTER));
            result[index++] = new ClasspathAccessRule(new Path(pattern),
                    ignoreIfBetter ? kind | IAccessRule.IGNORE_IF_BETTER : kind);
        }
    }
    if (index != length) {
        System.arraycopy(result, 0, result = new IAccessRule[index], 0, index);
    }
    return result;
}