Example usage for org.eclipse.jdt.core IAccessRule getPattern

List of usage examples for org.eclipse.jdt.core IAccessRule getPattern

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IAccessRule getPattern.

Prototype

IPath getPattern();

Source Link

Document

Returns the file pattern for this access rule.

Usage

From source file:com.codenvy.ide.ext.java.server.core.launching.environments.ExecutionEnvironment.java

License:Open Source License

/**
 * Adds the access rules to each list in the given collection. If the last rule in a
 * given collection is the wild card pattern then no more rules are added to that collection.
 *
 * @param accessRules the list of {@link org.eclipse.jdt.core.IAccessRule}s
 * @param collect the array of lists to collect the {@link org.eclipse.jdt.core.IAccessRule}s in
 *///from   w w w .j a va  2s  .  c o  m
private void addRules(IAccessRule[][] accessRules, ArrayList<List<IAccessRule>> collect) {
    for (int i = 0; i < accessRules.length; i++) {
        IAccessRule[] libRules = accessRules[i];
        List<IAccessRule> list = collect.get(i);
        // if the last rule is a **/* pattern, don't add any more rules, as they will have no effect
        if (!list.isEmpty()) {
            IAccessRule lastRule = list.get(list.size() - 1);
            if (lastRule.getPattern().equals(ALL_PATTERN)) {
                continue;
            }
        }
        for (int j = 0; j < libRules.length; j++) {
            list.add(libRules[j]);
        }
    }
}

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());
        }//  w w w .  j  a va  2s.c o  m
        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);
        }//from  w  w  w .j ava  2 s. com
        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: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 ww  . j  a v a  2s. c o 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;/*www  . jav a 2s .  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;
}