List of usage examples for org.eclipse.jdt.internal.core ClasspathAccessRule ClasspathAccessRule
public ClasspathAccessRule(char[] pattern, int problemId)
From source file:com.codenvy.ide.ext.java.server.internal.core.ClasspathEntry.java
License:Open Source License
static IAccessRule[] decodeAccessRules(NodeList list) { if (list == null) return null; int length = list.getLength(); if (length == 0) return null; IAccessRule[] result = new IAccessRule[length]; int index = 0; for (int i = 0; i < length; i++) { Node accessRule = list.item(i); if (accessRule.getNodeType() == Node.ELEMENT_NODE) { Element elementAccessRule = (Element) accessRule; String pattern = elementAccessRule.getAttribute(TAG_PATTERN); if (pattern == null) continue; String tagKind = elementAccessRule.getAttribute(TAG_KIND); int kind; if (TAG_ACCESSIBLE.equals(tagKind)) kind = IAccessRule.K_ACCESSIBLE; else if (TAG_NON_ACCESSIBLE.equals(tagKind)) kind = IAccessRule.K_NON_ACCESSIBLE; else if (TAG_DISCOURAGED.equals(tagKind)) kind = IAccessRule.K_DISCOURAGED; else// w ww.j a va 2 s . c o m continue; boolean ignoreIfBetter = "true".equals(elementAccessRule.getAttribute(TAG_IGNORE_IF_BETTER)); //$NON-NLS-1$ 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; }
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;
}/*from w ww . jav a2 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;
}
From source file:net.sf.j2s.core.builder.State.java
License:Open Source License
private static AccessRuleSet readRestriction(DataInputStream in) throws IOException { int length = in.readInt(); if (length == 0) return null; // no restriction specified AccessRule[] accessRules = new AccessRule[length]; for (int i = 0; i < length; i++) { char[] pattern = readName(in); int problemId = in.readInt(); accessRules[i] = new ClasspathAccessRule(pattern, problemId); }// ww w. j ava 2s .c o m JavaModelManager manager = JavaModelManager.getJavaModelManager(); return new AccessRuleSet(accessRules, in.readByte(), manager.intern(in.readUTF())); }
From source file:org.drools.eclipse.util.DroolsClasspathContainer.java
License:Apache License
private IClasspathEntry[] createDroolsLibraryEntries(IJavaProject project) { int internalAPI = DroolsEclipsePlugin.getDefault().getPluginPreferences() .getInt(IDroolsConstants.INTERNAL_API); String[] jarNames = getJarNames(project); List<IClasspathEntry> list = new ArrayList<IClasspathEntry>(); if (jarNames != null) { for (int i = 0; i < jarNames.length; i++) { Path path = new Path(jarNames[i]); if (internalAPI != 0) { if (jarNames[i].contains("knowledge-api")) { list.add(JavaCore.newLibraryEntry(path, path, null)); } else { IAccessRule[] accessRules = new IAccessRule[1]; accessRules[0] = new ClasspathAccessRule(new Path("**"), internalAPI); list.add(JavaCore.newLibraryEntry(path, path, null, accessRules, ClasspathEntry.NO_EXTRA_ATTRIBUTES, false)); }//from w w w .j a v a2s. c om } } } return (IClasspathEntry[]) list.toArray(new IClasspathEntry[list.size()]); }