List of usage examples for org.eclipse.jdt.core IAccessRule getKind
int getKind();
From source file:com.google.cloud.tools.eclipse.appengine.libraries.persistence.LibraryClasspathContainerSerializerTest.java
License:Apache License
private void compare(LibraryClasspathContainer container, LibraryClasspathContainer otherContainer) { assertEquals(container.getPath(), otherContainer.getPath()); assertEquals(container.getKind(), otherContainer.getKind()); assertEquals(container.getDescription(), otherContainer.getDescription()); for (int i = 0; i < container.getClasspathEntries().length; i++) { IClasspathEntry classpathEntry = container.getClasspathEntries()[i]; IClasspathEntry otherClasspathEntry = otherContainer.getClasspathEntries()[i]; assertEquals(classpathEntry.getPath(), otherClasspathEntry.getPath()); assertEquals(classpathEntry.getEntryKind(), otherClasspathEntry.getEntryKind()); assertEquals(classpathEntry.getSourceAttachmentPath(), otherClasspathEntry.getSourceAttachmentPath()); assertEquals(classpathEntry.isExported(), otherClasspathEntry.isExported()); for (int j = 0; j < classpathEntry.getAccessRules().length; j++) { IAccessRule accessRule = classpathEntry.getAccessRules()[j]; IAccessRule otherAccessRule = otherClasspathEntry.getAccessRules()[j]; assertEquals(accessRule.getKind(), otherAccessRule.getKind()); assertEquals(accessRule.getPattern(), otherAccessRule.getPattern()); }//from w ww . j a v a2 s . com for (int k = 0; k < classpathEntry.getExtraAttributes().length; k++) { IClasspathAttribute classpathAttribute = classpathEntry.getExtraAttributes()[k]; IClasspathAttribute otherClasspathAttribute = otherClasspathEntry.getExtraAttributes()[k]; assertEquals(classpathAttribute.getName(), otherClasspathAttribute.getName()); assertEquals(classpathAttribute.getValue(), otherClasspathAttribute.getValue()); } } }
From source file:com.google.cloud.tools.eclipse.appengine.libraries.persistence.SerializableAccessRules.java
License:Apache License
public SerializableAccessRules(IAccessRule rule) { ruleKind = AccessRuleKind.forInt(rule.getKind()); pattern = rule.getPattern().toString(); }
From source file:com.redhat.ceylon.eclipse.code.preferences.ResourceListLabelProvider.java
License:Open Source License
@Override public String getText(Object element) { if (element instanceof CPListElement) { return getCPListElementText((CPListElement) element); } else if (element instanceof CPListElementAttribute) { CPListElementAttribute attribute = (CPListElementAttribute) element; String text = getCPListElementAttributeText(attribute); if (attribute.isNonModifiable()) { return Messages.format(NewWizardMessages.CPListLabelProvider_non_modifiable_attribute, text); }// w w w. jav a 2 s. c o m return text; } else if (element instanceof CPUserLibraryElement) { return getCPUserLibraryText((CPUserLibraryElement) element); } else if (element instanceof IAccessRule) { IAccessRule rule = (IAccessRule) element; return Messages.format(NewWizardMessages.CPListLabelProvider_access_rules_label, new String[] { AccessRulesLabelProvider.getResolutionLabel(rule.getKind()), BasicElementLabels.getPathLabel(rule.getPattern(), false) }); } return super.getText(element); }
From source file:com.redhat.ceylon.eclipse.code.preferences.ResourceListLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { if (element instanceof CPListElement) { CPListElement cpentry = (CPListElement) element; return getCPListElementBaseImage(cpentry); // ImageDescriptor imageDescriptor= getCPListElementBaseImage(cpentry); // if (imageDescriptor != null) { // if (cpentry.isMissing() || cpentry.hasMissingChildren()) { // imageDescriptor= new JavaElementImageDescriptor(imageDescriptor, JavaElementImageDescriptor.ERROR, JavaElementImageProvider.SMALL_SIZE); // } // return fRegistry.get(imageDescriptor); // } } else if (element instanceof CPListElementAttribute) { CPListElementAttribute attribute = (CPListElementAttribute) element; String key = (attribute).getKey(); if (key.equals(CPListElement.SOURCEATTACHMENT)) { return fRegistry.get(JavaPluginImages.DESC_OBJS_SOURCE_ATTACH_ATTRIB); } else if (key.equals(CPListElement.OUTPUT)) { return fRegistry.get(JavaPluginImages.DESC_OBJS_OUTPUT_FOLDER_ATTRIB); } else if (key.equals(CPListElement.EXCLUSION)) { return fRegistry.get(JavaPluginImages.DESC_OBJS_EXCLUSION_FILTER_ATTRIB); } else if (key.equals(CPListElement.INCLUSION)) { return fRegistry.get(JavaPluginImages.DESC_OBJS_INCLUSION_FILTER_ATTRIB); } else if (key.equals(CPListElement.ACCESSRULES)) { return fRegistry.get(JavaPluginImages.DESC_OBJS_ACCESSRULES_ATTRIB); } else if (key.equals(CPListElement.IGNORE_OPTIONAL_PROBLEMS)) { Image image = getCPListElementBaseImage(attribute.getParent()); if (image != null) { ImageDescriptor overlay = JavaPluginImages.DESC_OVR_IGNORE_OPTIONAL_PROBLEMS; ImageDescriptor imageDescriptor = new DecorationOverlayIcon(image, overlay, IDecoration.BOTTOM_LEFT); return fRegistry.get(imageDescriptor); }//from w ww . java 2 s .com } else { ClasspathAttributeConfiguration config = fAttributeDescriptors.get(key); if (config != null) { return fRegistry.get(config.getImageDescriptor(attribute.getClasspathAttributeAccess())); } } return fSharedImages.getImage(ISharedImages.IMG_OBJS_CLASSPATH_VAR_ENTRY); } else if (element instanceof CPUserLibraryElement) { if (((CPUserLibraryElement) element).hasMissingChildren()) { ImageDescriptor descriptor = fSharedImages.getImageDescriptor(ISharedImages.IMG_OBJS_LIBRARY); if (descriptor != null) { return fRegistry.get(new JavaElementImageDescriptor(descriptor, JavaElementImageDescriptor.ERROR, JavaElementImageProvider.SMALL_SIZE)); } } return fSharedImages.getImage(ISharedImages.IMG_OBJS_LIBRARY); } else if (element instanceof IAccessRule) { IAccessRule rule = (IAccessRule) element; return AccessRulesLabelProvider.getResolutionImage(rule.getKind()); } return null; }
From source file:edu.brown.cs.bubbles.bedrock.BedrockProject.java
License:Open Source License
private void addPath(IvyXmlWriter xw, IJavaProject jp, IClasspathEntry ent, boolean nest) { IPath p = ent.getPath();/*w w w . j av a 2 s .co m*/ IPath op = ent.getOutputLocation(); IPath sp = ent.getSourceAttachmentPath(); IProject ip = jp.getProject(); String jdp = null; boolean opt = false; IClasspathAttribute[] atts = ent.getExtraAttributes(); for (IClasspathAttribute att : atts) { if (att.getName().equals(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME)) jdp = att.getValue(); else if (att.getName().equals(IClasspathAttribute.OPTIONAL)) { String v = att.getValue(); if (v.equals("true")) opt = true; } } if (p == null && op == null) return; File f1 = null; if (p != null) { f1 = BedrockUtil.getFileForPath(p, ip); if (!f1.exists()) { BedrockPlugin.logD("Path file " + p + " not found as " + f1); // f1 = null; } } File f2 = null; if (op != null) { f2 = BedrockUtil.getFileForPath(op, ip); if (!f2.exists()) { BedrockPlugin.logD("Path file " + op + " not found"); f2 = null; } } File f3 = null; if (sp != null) { f3 = BedrockUtil.getFileForPath(sp, ip); if (!f3.exists()) { BedrockPlugin.logD("Path file " + sp + " not found"); f3 = null; } } if (f1 == null && f2 == null) return; // references to nested projects are handled in addClassPaths if (ent.getEntryKind() == IClasspathEntry.CPE_PROJECT) return; xw.begin("PATH"); xw.field("ID", ent.hashCode()); if (nest) xw.field("NESTED", "TRUE"); switch (ent.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: xw.field("TYPE", "SOURCE"); f3 = f1; f1 = null; break; case IClasspathEntry.CPE_PROJECT: xw.field("TYPE", "BINARY"); break; case IClasspathEntry.CPE_LIBRARY: xw.field("TYPE", "LIBRARY"); break; } if (ent.isExported()) xw.field("EXPORTED", true); if (opt) xw.field("OPTIONAL", true); if (f1 != null) xw.textElement("BINARY", f1.getAbsolutePath()); if (f2 != null) xw.textElement("OUTPUT", f2.getAbsolutePath()); if (f3 != null) xw.textElement("SOURCE", f3.getAbsolutePath()); if (jdp != null) xw.textElement("JAVADOC", jdp); IAccessRule[] rls = ent.getAccessRules(); for (IAccessRule ar : rls) { xw.begin("ACCESS"); xw.field("KIND", ar.getKind()); xw.field("PATTERN", ar.getPattern().toString()); xw.field("IGNOREIFBETTER", ar.ignoreIfBetter()); xw.end("ACCESS"); } xw.end("PATH"); }
From source file:org.eclipse.virgo.ide.jdt.internal.core.classpath.ServerClasspathContainer.java
License:Open Source License
private IAccessRule[] mergeAccessRules(List<IClasspathEntry> entries, IPath path, IAccessRule... allowedRules) { IClasspathEntry entry = null;//from ww w. j ava2s. c o m // Check if the path is already in and merge if so for (IClasspathEntry existingEntry : entries) { if (existingEntry.getPath().equals(path)) { Set<IAccessRule> existingRules = new TreeSet<IAccessRule>(new Comparator<IAccessRule>() { public int compare(IAccessRule o1, IAccessRule o2) { if (o1.getKind() == o2.getKind()) { return o1.getPattern().toString().compareTo(o2.getPattern().toString()); } else if (o1.getKind() == IAccessRule.K_NON_ACCESSIBLE) { return 1; } else if (o2.getKind() == IAccessRule.K_NON_ACCESSIBLE) { return -1; } else if (o1.getKind() == IAccessRule.K_ACCESSIBLE) { return 1; } else if (o2.getKind() == IAccessRule.K_ACCESSIBLE) { return -1; } return 0; } }); existingRules.addAll(Arrays.asList(existingEntry.getAccessRules())); existingRules.addAll(Arrays.asList(allowedRules)); allowedRules = existingRules.toArray(new IAccessRule[existingRules.size()]); entry = existingEntry; break; } } if (entry != null) { entries.remove(entry); } return allowedRules; }
From source file:org.eclipse.xtext.xbase.ui.validation.XbaseUIValidator.java
License:Open Source License
protected RestrictionKind computeRestriction(IJavaProject project, IType type) { try {//from www. j ava 2 s. c om IPackageFragmentRoot root = (IPackageFragmentRoot) type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (root == null) { return RestrictionKind.VALID; } IClasspathEntry entry = getResolvedClasspathEntry(project, root); if (entry == null) { return RestrictionKind.VALID; } IAccessRule[] rules = entry.getAccessRules(); String typePath = type.getFullyQualifiedName().replace('.', '/'); char[] typePathAsArray = typePath.toCharArray(); for (IAccessRule rule : rules) { char[] patternArray = ((ClasspathAccessRule) rule).pattern; if (CharOperation.pathMatch(patternArray, typePathAsArray, true, '/')) { if (rule.getKind() == IAccessRule.K_DISCOURAGED) { return RestrictionKind.DISCOURAGED; } else if (rule.getKind() == IAccessRule.K_NON_ACCESSIBLE) { return RestrictionKind.FORBIDDEN; } return RestrictionKind.VALID; } } } catch (JavaModelException jme) { // ignore } return RestrictionKind.VALID; }