Java 类org.eclipse.jdt.core.IClasspathAttribute 实例源码

项目:google-cloud-eclipse    文件:CreateAppEngineFlexWtpProject.java   
private void addDependenciesToClasspath(IProject project, IFolder folder,
    IProgressMonitor monitor)  throws CoreException {
  List<IClasspathEntry> newEntries = new ArrayList<>();

  IClasspathAttribute[] nonDependencyAttribute =
      new IClasspathAttribute[] {UpdateClasspathAttributeUtil.createNonDependencyAttribute()};

  // Add all the jars under lib folder to the classpath
  File libFolder = folder.getLocation().toFile();
  for (File file : libFolder.listFiles()) {
    IPath path = Path.fromOSString(file.toPath().toString());
    newEntries.add(JavaCore.newLibraryEntry(path, null, null, new IAccessRule[0],
        nonDependencyAttribute, false /* isExported */));
  }

  ClasspathUtil.addClasspathEntries(project, newEntries, monitor);
}
项目:google-cloud-eclipse    文件:MavenCoordinatesHelperTest.java   
@Test
public void testCreateClasspathAttributesWithClassifier() {
  MavenCoordinates mavenCoordinates = builder.setClassifier("classifier").build();

  List<IClasspathAttribute> classpathAttributes =
      MavenCoordinatesHelper.createClasspathAttributes(mavenCoordinates, "1.0.0");
  assertAttribute(classpathAttributes,
                  "com.google.cloud.tools.eclipse.appengine.libraries.repository", "testRepo");
  assertAttribute(classpathAttributes,
                  "com.google.cloud.tools.eclipse.appengine.libraries.groupid", "groupId");
  assertAttribute(classpathAttributes,
                  "com.google.cloud.tools.eclipse.appengine.libraries.artifactId", "artifactId");
  assertAttribute(classpathAttributes,
                  "com.google.cloud.tools.eclipse.appengine.libraries.type", "war");
  assertAttribute(classpathAttributes,
                  "com.google.cloud.tools.eclipse.appengine.libraries.version", "1.0.0");
  assertAttribute(classpathAttributes,
                  "com.google.cloud.tools.eclipse.appengine.libraries.classifier", "classifier");
}
项目:google-cloud-eclipse    文件:LibraryClasspathContainerResolverService.java   
private static IClasspathAttribute[] getClasspathAttributes(LibraryFile libraryFile,
                                                            Artifact artifact)
                                                                throws CoreException {
  List<IClasspathAttribute> attributes =
      MavenCoordinatesHelper.createClasspathAttributes(libraryFile.getMavenCoordinates(),
                                                       artifact.getVersion());
  if (libraryFile.isExport()) {
    attributes.add(UpdateClasspathAttributeUtil.createDependencyAttribute(true /* isWebApp */));
  } else {
    attributes.add(UpdateClasspathAttributeUtil.createNonDependencyAttribute());
  }
  if (libraryFile.getSourceUri() != null) {
    addUriAttribute(attributes, CLASSPATH_ATTRIBUTE_SOURCE_URL, libraryFile.getSourceUri());
  }
  if (libraryFile.getJavadocUri() != null) {
    addUriAttribute(attributes, IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
                    libraryFile.getJavadocUri());
  }
  return attributes.toArray(new IClasspathAttribute[0]);
}
项目:google-cloud-eclipse    文件:MavenCoordinatesHelper.java   
public static List<IClasspathAttribute> createClasspathAttributes(MavenCoordinates mavenCoordinates,
                                                                  String actualVersion) {
  List<IClasspathAttribute> attributes = Lists.newArrayList(
      JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_REPOSITORY,
                                     mavenCoordinates.getRepository()),
      JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_GROUP_ID,
                                     mavenCoordinates.getGroupId()),
      JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_ARTIFACT_ID,
                                     mavenCoordinates.getArtifactId()),
      JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_TYPE,
                                     mavenCoordinates.getType()),
      JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_VERSION,
                                     actualVersion)
      );
  if (mavenCoordinates.getClassifier() != null) {
    attributes.add(JavaCore.newClasspathAttribute(CLASSPATH_ATTRIBUTE_CLASSIFIER,
                                                  mavenCoordinates.getClassifier()));
  }
  return attributes;
}
项目:che    文件:ClasspathEntry.java   
static IClasspathAttribute[] decodeExtraAttributes(NodeList attributes) {
  if (attributes == null) return NO_EXTRA_ATTRIBUTES;
  int length = attributes.getLength();
  if (length == 0) return NO_EXTRA_ATTRIBUTES;
  IClasspathAttribute[] result = new IClasspathAttribute[length];
  int index = 0;
  for (int i = 0; i < length; ++i) {
    Node node = attributes.item(i);
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      Element attribute = (Element) node;
      String name = attribute.getAttribute(TAG_ATTRIBUTE_NAME);
      if (name == null) continue;
      String value = attribute.getAttribute(TAG_ATTRIBUTE_VALUE);
      if (value == null) continue;
      result[index++] = new ClasspathAttribute(name, value);
    }
  }
  if (index != length)
    System.arraycopy(result, 0, result = new IClasspathAttribute[index], 0, index);
  return result;
}
项目:che    文件:ClasspathEntry.java   
/**
 * This function computes the URL of the index location for this classpath entry. It returns null
 * if the URL is invalid.
 */
public URL getLibraryIndexLocation() {
  switch (getEntryKind()) {
    case IClasspathEntry.CPE_LIBRARY:
    case IClasspathEntry.CPE_VARIABLE:
      break;
    default:
      return null;
  }
  if (this.extraAttributes == null) return null;
  for (int i = 0; i < this.extraAttributes.length; i++) {
    IClasspathAttribute attrib = this.extraAttributes[i];
    if (IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
      String value = attrib.getValue();
      try {
        return new URL(value);
      } catch (MalformedURLException e) {
        return null;
      }
    }
  }
  return null;
}
项目:che    文件:JavaDocLocations.java   
public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
  if (entry == null) {
    throw new IllegalArgumentException("Entry must not be null"); // $NON-NLS-1$
  }

  int kind = entry.getEntryKind();
  if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
    throw new IllegalArgumentException(
        "Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); // $NON-NLS-1$
  }

  IClasspathAttribute[] extraAttributes = entry.getExtraAttributes();
  for (int i = 0; i < extraAttributes.length; i++) {
    IClasspathAttribute attrib = extraAttributes[i];
    if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
      return parseURL(attrib.getValue());
    }
  }
  return null;
}
项目:che    文件:JavadocContentAccess2.java   
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root)
    throws JavaModelException {
  String encoding = ResourcesPlugin.getEncoding();
  IClasspathEntry entry = root.getRawClasspathEntry();

  if (entry != null) {
    int kind = entry.getEntryKind();
    if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) {
      IClasspathAttribute[] extraAttributes = entry.getExtraAttributes();
      for (int i = 0; i < extraAttributes.length; i++) {
        IClasspathAttribute attrib = extraAttributes[i];
        if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
          return attrib.getValue();
        }
      }
    }
  }

  return encoding;
}
项目:che    文件:JREContainer.java   
private static IClasspathAttribute[] buildClasspathAttributes(
    final IVMInstallType vm, final LibraryLocation lib, final boolean overrideJavaDoc) {

  List<IClasspathAttribute> classpathAttributes = new LinkedList<IClasspathAttribute>();
  // process the javadoc location
  URL javadocLocation = lib.getJavadocLocation();
  if (overrideJavaDoc && javadocLocation == null) {
    javadocLocation = null; // vm.getJavadocLocation();
  }
  if (javadocLocation != null) {
    IClasspathAttribute javadocCPAttribute =
        JavaCore.newClasspathAttribute(
            IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
            javadocLocation.toExternalForm());
    classpathAttributes.add(javadocCPAttribute);
  }
  // process the index location
  URL indexLocation = lib.getIndexLocation();
  if (indexLocation != null) {
    IClasspathAttribute indexCPLocation =
        JavaCore.newClasspathAttribute(
            IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, indexLocation.toExternalForm());
    classpathAttributes.add(indexCPLocation);
  }
  return classpathAttributes.toArray(new IClasspathAttribute[classpathAttributes.size()]);
}
项目:che    文件:ClasspathManager.java   
private MavenArtifactKey getArtifactKey(IClasspathEntry classpathEntry) {
  IClasspathAttribute[] attributes = classpathEntry.getExtraAttributes();
  String groupId = null;
  String artifactId = null;
  String version = null;
  String packaging = null;
  String classifier = null;
  for (IClasspathAttribute attribute : attributes) {
    if (ClasspathManager.GROUP_ID_ATTRIBUTE.equals(attribute.getName())) {
      groupId = attribute.getValue();
    } else if (ClasspathManager.ARTIFACT_ID_ATTRIBUTE.equals(attribute.getName())) {
      artifactId = attribute.getValue();
    } else if (ClasspathManager.VERSION_ATTRIBUTE.equals(attribute.getName())) {
      version = attribute.getValue();
    } else if (ClasspathManager.PACKAGING_ATTRIBUTE.equals(attribute.getName())) {
      packaging = attribute.getValue();
    } else if (ClasspathManager.CLASSIFIER_ATTRIBUTE.equals(attribute.getName())) {
      classifier = attribute.getValue();
    }
  }

  if (groupId != null && artifactId != null && version != null) {
    return new MavenArtifactKey(groupId, artifactId, version, packaging, classifier);
  }
  return null;
}
项目:gwt-eclipse-plugin    文件:GWTRuntimeTest.java   
/**
 * Tests that we find an {@link com.google.gdt.eclipse.core.sdk.Sdk} on the
 * gwt-user project.
 *
 * @throws Exception
 */
public void testFindSdkFor_GwtUserProject() throws Exception {
  GwtRuntimeTestUtilities.importGwtSourceProjects();
  try {
    IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
    IJavaProject javaProject = javaModel.getJavaProject("gwt-user");
    GwtSdk sdk = GwtSdk.findSdkFor(javaProject);
    IClasspathEntry gwtUserEntry =
        JavaCore.newSourceEntry(
            javaModel.getJavaProject("gwt-user").getPath().append("core/src"),
            new IPath[] {new Path("**/super/**")});
    /*
     * NOTE: Passing null for the IClasspathAttribute array tickles a bug in
     * eclipse 3.3.
     */
    IClasspathEntry gwtDevEntry =
        JavaCore.newProjectEntry(javaModel.getJavaProject("gwt-dev").getPath(), null, false,
            new IClasspathAttribute[0] /* */, false);
    IClasspathEntry[] expected = new IClasspathEntry[] {gwtUserEntry, gwtDevEntry};
    assertEquals(expected, sdk.getClasspathEntries());
  } finally {
    GwtRuntimeTestUtilities.removeGwtSourceProjects();
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaDocLocations.java   
public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
    if (entry == null) {
        throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$
    }

    int kind= entry.getEntryKind();
    if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
        throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$
    }

    IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
    for (int i= 0; i < extraAttributes.length; i++) {
        IClasspathAttribute attrib= extraAttributes[i];
        if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
            return parseURL(attrib.getValue());
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocContentAccess2.java   
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root) throws JavaModelException {
    String encoding= ResourcesPlugin.getEncoding();
    IClasspathEntry entry= root.getRawClasspathEntry();

    if (entry != null) {
        int kind= entry.getEntryKind();
        if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) {
            IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
            for (int i= 0; i < extraAttributes.length; i++) {
                IClasspathAttribute attrib= extraAttributes[i];
                if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
                    return attrib.getValue();
                }
            }
        }
    }

    return encoding;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocConfigurationPropertyPage.java   
private IClasspathEntry handleContainerEntry(IPath containerPath, IJavaProject jproject, IPath jarPath) throws JavaModelException {
    ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
    IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject);
    if (initializer == null || container == null) {
        setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false)));
        return null;
    }
    String containerName= container.getDescription();
    IStatus status= initializer.getAttributeStatus(containerPath, jproject, IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME);
    if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
        setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_not_supported, containerName));
        return null;
    }
    IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath);
    if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) {
        setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_read_only, containerName));
        fIsReadOnly= true;
        return entry;
    }
    Assert.isNotNull(entry);
    setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description);
    return entry;
}
项目:Eclipse-Postfix-Code-Completion    文件:OptionsConfigurationBlock.java   
protected Link createIgnoreOptionalProblemsLink(Composite parent) {
    final IClasspathEntry sourceFolderEntry= getSourceFolderIgnoringOptionalProblems();
    if (sourceFolderEntry != null) {
        Link link= new Link(parent, SWT.NONE);
        link.setText(PreferencesMessages.OptionsConfigurationBlock_IgnoreOptionalProblemsLink);
        link.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                HashMap<Object, Object> data= new HashMap<Object, Object>(1);
                data.put(BuildPathsPropertyPage.DATA_REVEAL_ENTRY, sourceFolderEntry);
                data.put(BuildPathsPropertyPage.DATA_REVEAL_ATTRIBUTE_KEY, IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS);
                getPreferenceContainer().openPage(BuildPathsPropertyPage.PROP_ID, data);
            }
        });
        return link;
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:CPListElementAttribute.java   
public ClasspathAttributeAccess getClasspathAttributeAccess() {
    if (fCachedAccess == null) {
    fCachedAccess= new ClasspathAttributeAccess() {
        @Override
public IClasspathAttribute getClasspathAttribute() {
        return CPListElementAttribute.this.getClasspathAttribute();
}
@Override
public IJavaProject getJavaProject() {
    return getParent().getJavaProject();
}
@Override
public IClasspathEntry getParentClasspassEntry() {
    return getParent().getClasspathEntry();
}
    };
    }
    return fCachedAccess;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavadocAttributeConfiguration.java   
@Override
public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) {
    String initialLocation= attribute.getClasspathAttribute().getValue();
    String elementName= attribute.getParentClasspassEntry().getPath().lastSegment();
    try {
        URL locationURL= initialLocation != null ? new URL(initialLocation) : null;
        URL[] result= BuildPathDialogAccess.configureJavadocLocation(shell, elementName, locationURL);
        if (result != null) {
            URL newURL= result[0];
            String string= newURL != null ? newURL.toExternalForm() : null;
            return JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, string);
        }
    } catch (MalformedURLException e) {
        // todo
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:SourceAttachmentBlock.java   
public static String getSourceAttachmentEncoding(IClasspathEntry entry) {
    if (entry == null) {
        throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$
    }

    int kind= entry.getEntryKind();
    if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
        throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$
    }

    IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
    for (int i= 0; i < extraAttributes.length; i++) {
        IClasspathAttribute attrib= extraAttributes[i];
        if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
            return attrib.getValue();
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:ClasspathEntry.java   
static IClasspathAttribute[] decodeExtraAttributes(NodeList attributes) {
    if (attributes == null) return NO_EXTRA_ATTRIBUTES;
    int length = attributes.getLength();
    if (length == 0) return NO_EXTRA_ATTRIBUTES;
    IClasspathAttribute[] result = new IClasspathAttribute[length];
    int index = 0;
    for (int i = 0; i < length; ++i) {
        Node node = attributes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element attribute = (Element)node;
            String name = attribute.getAttribute(TAG_ATTRIBUTE_NAME);
            if (name == null) continue;
            String value = attribute.getAttribute(TAG_ATTRIBUTE_VALUE);
            if (value == null) continue;
            result[index++] = new ClasspathAttribute(name, value);
        }
    }
    if (index != length)
        System.arraycopy(result, 0, result = new IClasspathAttribute[index], 0, index);
    return result;
}
项目:Eclipse-Postfix-Code-Completion    文件:ClasspathEntry.java   
/**
 * This function computes the URL of the index location for this classpath entry. It returns null if the URL is
 * invalid.
 */
public URL getLibraryIndexLocation() {
    switch(getEntryKind()) {
        case IClasspathEntry.CPE_LIBRARY :
        case IClasspathEntry.CPE_VARIABLE :
            break;
        default :
            return null;
    }
    if (this.extraAttributes == null) return null;
    for (int i= 0; i < this.extraAttributes.length; i++) {
        IClasspathAttribute attrib= this.extraAttributes[i];
        if (IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
            String value = attrib.getValue();
            try {
                return new URL(value);
            } catch (MalformedURLException e) {
                return null;
            }
        }
    }
    return null;
}
项目:JettyWTPPlugin    文件:ModuleTraverser.java   
private static Map getRawComponentClasspathDependencies(final IJavaProject javaProject) throws CoreException
{
    if (javaProject == null)
    {
        return Collections.EMPTY_MAP;
    }
    final Map referencedRawEntries = new HashMap();
    final IClasspathEntry[] entries = javaProject.getRawClasspath();
    for (int i = 0; i < entries.length; i++)
    {
        final IClasspathEntry entry = entries[i];
        final IClasspathAttribute attrib = checkForComponentDependencyAttribute(entry,DEPENDECYATTRIBUTETYPE_CLASSPATH_COMPONENT_DEPENDENCY);
        if (attrib != null)
        {
            referencedRawEntries.put(entry,attrib);
        }
    }
    return referencedRawEntries;
}
项目:JettyWTPPlugin    文件:ModuleTraverser.java   
private static String getRuntimePath(final IClasspathAttribute attrib, final boolean isWebApp, final boolean isClassFolder)
{
    if (attrib != null && !attrib.getName().equals(CLASSPATH_COMPONENT_DEPENDENCY))
    {
        return null;
    }
    if (attrib == null || attrib.getValue() == null || attrib.getValue().length() == 0)
    {
        if (isWebApp)
        {
            return isClassFolder?"/WEB_INF/classes":"WEB-INF/lib";
        }
        else
        {
            return isClassFolder?"/":"../";
        }
    }
    return attrib.getValue();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaDocLocations.java   
public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
    if (entry == null) {
        throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$
    }

    int kind= entry.getEntryKind();
    if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
        throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$
    }

    IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
    for (int i= 0; i < extraAttributes.length; i++) {
        IClasspathAttribute attrib= extraAttributes[i];
        if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
            try {
                return new URL(attrib.getValue());
            } catch (MalformedURLException e) {
                return null;
            }
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocConfigurationPropertyPage.java   
private IClasspathEntry handleContainerEntry(IPath containerPath, IJavaProject jproject, IPath jarPath) throws JavaModelException {
    ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
    IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject);
    if (initializer == null || container == null) {
        setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false)));
        return null;
    }
    String containerName= container.getDescription();
    IStatus status= initializer.getAttributeStatus(containerPath, jproject, IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME);
    if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
        setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_not_supported, containerName));
        return null;
    }
    IClasspathEntry entry= JavaModelUtil.findEntryInContainer(container, jarPath);
    if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) {
        setDescription(Messages.format(PreferencesMessages.JavadocConfigurationPropertyPage_read_only, containerName));
        fIsReadOnly= true;
        return entry;
    }
    Assert.isNotNull(entry);
    setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description);
    return entry;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:OptionsConfigurationBlock.java   
protected Link createIgnoreOptionalProblemsLink(Composite parent) {
    final IClasspathEntry sourceFolderEntry= getSourceFolderIgnoringOptionalProblems();
    if (sourceFolderEntry != null) {
        Link link= new Link(parent, SWT.NONE);
        link.setText(PreferencesMessages.OptionsConfigurationBlock_IgnoreOptionalProblemsLink);
        link.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                HashMap<Object, Object> data= new HashMap<Object, Object>(1);
                data.put(BuildPathsPropertyPage.DATA_REVEAL_ENTRY, sourceFolderEntry);
                data.put(BuildPathsPropertyPage.DATA_REVEAL_ATTRIBUTE_KEY, IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS);
                getPreferenceContainer().openPage(BuildPathsPropertyPage.PROP_ID, data);
            }
        });
        return link;
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CPListElementAttribute.java   
public ClasspathAttributeAccess getClasspathAttributeAccess() {
    if (fCachedAccess == null) {
    fCachedAccess= new ClasspathAttributeAccess() {
        @Override
public IClasspathAttribute getClasspathAttribute() {
        return CPListElementAttribute.this.getClasspathAttribute();
}
@Override
public IJavaProject getJavaProject() {
    return getParent().getJavaProject();
}
@Override
public IClasspathEntry getParentClasspassEntry() {
    return getParent().getClasspathEntry();
}
    };
    }
    return fCachedAccess;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocAttributeConfiguration.java   
@Override
public IClasspathAttribute performEdit(Shell shell, ClasspathAttributeAccess attribute) {
    String initialLocation= attribute.getClasspathAttribute().getValue();
    String elementName= attribute.getParentClasspassEntry().getPath().lastSegment();
    try {
        URL locationURL= initialLocation != null ? new URL(initialLocation) : null;
        URL[] result= BuildPathDialogAccess.configureJavadocLocation(shell, elementName, locationURL);
        if (result != null) {
            URL newURL= result[0];
            String string= newURL != null ? newURL.toExternalForm() : null;
            return JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, string);
        }
    } catch (MalformedURLException e) {
        // todo
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SourceAttachmentBlock.java   
public static String getSourceAttachmentEncoding(IClasspathEntry entry) {
    if (entry == null) {
        throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$
    }

    int kind= entry.getEntryKind();
    if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
        throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$
    }

    IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
    for (int i= 0; i < extraAttributes.length; i++) {
        IClasspathAttribute attrib= extraAttributes[i];
        if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) {
            return attrib.getValue();
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClasspathEntry.java   
static IClasspathAttribute[] decodeExtraAttributes(NodeList attributes) {
    if (attributes == null) return NO_EXTRA_ATTRIBUTES;
    int length = attributes.getLength();
    if (length == 0) return NO_EXTRA_ATTRIBUTES;
    IClasspathAttribute[] result = new IClasspathAttribute[length];
    int index = 0;
    for (int i = 0; i < length; ++i) {
        Node node = attributes.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element attribute = (Element)node;
            String name = attribute.getAttribute(TAG_ATTRIBUTE_NAME);
            if (name == null) continue;
            String value = attribute.getAttribute(TAG_ATTRIBUTE_VALUE);
            if (value == null) continue;
            result[index++] = new ClasspathAttribute(name, value);
        }
    }
    if (index != length)
        System.arraycopy(result, 0, result = new IClasspathAttribute[index], 0, index);
    return result;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClasspathEntry.java   
/**
 * This function computes the URL of the index location for this classpath entry. It returns null if the URL is
 * invalid.
 */
public URL getLibraryIndexLocation() {
    switch(getEntryKind()) {
        case IClasspathEntry.CPE_LIBRARY :
        case IClasspathEntry.CPE_VARIABLE :
            break;
        default :
            return null;
    }
    if (this.extraAttributes == null) return null;
    for (int i= 0; i < this.extraAttributes.length; i++) {
        IClasspathAttribute attrib= this.extraAttributes[i];
        if (IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
            String value = attrib.getValue();
            try {
                return new URL(value);
            } catch (MalformedURLException e) {
                return null;
            }
        }
    }
    return null;
}
项目:ant-ivyde    文件:NewIvyDEContainerWizard.java   
public boolean performFinish() {
    containerPage.finish();
    IClasspathEntry newEntry = containerPage.getSelection();
    IPath path = newEntry.getPath();
    IJavaProject project = containerPage.getProject();
    try {
        IvyClasspathContainerImpl ivycp = new IvyClasspathContainerImpl(project, path,
                new IClasspathEntry[0], new IClasspathAttribute[0]);
        JavaCore.setClasspathContainer(path, new IJavaProject[] {project},
            new IClasspathContainer[] {ivycp}, null);
        IClasspathEntry[] entries = project.getRawClasspath();
        List<IClasspathEntry> newEntries = new ArrayList<>(Arrays.asList(entries));
        newEntries.add(newEntry);
        entries = newEntries.toArray(new IClasspathEntry[newEntries.size()]);
        project.setRawClasspath(entries, project.getOutputLocation(), null);
        ivycp.launchResolve(false, null);
    } catch (JavaModelException e) {
        IvyPlugin.log(e);
        return false;
    }
    return true;
}
项目:ant-ivyde    文件:IvyClasspathUtil.java   
/**
 * Just a verbatim copy of the internal Eclipse function:
 * org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations#getLibraryJavadocLocation(IClasspathEntry)
 *
 * @param entry IClasspathEntry
 * @return URL
 */
public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
    if (entry == null) {
        throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$
    }

    int kind = entry.getEntryKind();
    if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
        throw new IllegalArgumentException(
                "Entry must be of kind CPE_LIBRARY or " + "CPE_VARIABLE"); //$NON-NLS-1$
    }

    for (IClasspathAttribute attrib : entry.getExtraAttributes()) {
        if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
            try {
                return new URL(attrib.getValue());
            } catch (MalformedURLException e) {
                return null;
            }
        }
    }
    return null;
}
项目:ant-ivyde    文件:IvyClasspathContainerMapper.java   
private IClasspathEntry doBuildEntry(ArtifactDownloadReport artifact, IPath classpathArtifact,
        IAccessRule[] rules) {
    IPath sourcesArtifact = getArtifactPath(artifact, sourceArtifactMatcher,
        mapping.isMapIfOnlyOneSource(), "");
    IPath javadocArtifact = getArtifactPath(artifact, javadocArtifactMatcher,
        mapping.isMapIfOnlyOneJavadoc(), "");
    IPath sources = attachmentManager.getSourceAttachment(classpathArtifact, sourcesArtifact);
    IPath sourcesRoot = attachmentManager.getSourceAttachmentRoot(classpathArtifact,
        sourcesArtifact);
    IClasspathAttribute[] att = getExtraAttribute(classpathArtifact, javadocArtifact);

    if (sources != null) {
        IvyDEMessage.debug("Attaching sources " + sources + " to " + classpathArtifact);
    }
    if (javadocArtifact != null) {
        IvyDEMessage.debug("Attaching javadoc " + javadocArtifact + " to " + classpathArtifact);
    }
    if (rules != null) {
        IvyDEMessage.debug("Setting OSGi access rules on  " + classpathArtifact);
    }
    return JavaCore.newLibraryEntry(classpathArtifact, sources, sourcesRoot, rules, att, false);
}
项目:ant-ivyde    文件:IvyClasspathContainerSerializer.java   
private void writeCpAttr(IvyClasspathContainerImpl ivycp, Document document, Node node,
        IClasspathAttribute[] attrs) {
    if (attrs == null) {
        return;
    }
    Node cpAttrsNode = document.createElement(CPATTRS);
    node.appendChild(cpAttrsNode);

    for (IClasspathAttribute attribute : attrs) {
        Node attrNode = document.createElement(ATTR);
        cpAttrsNode.appendChild(attrNode);

        NamedNodeMap attributes = attrNode.getAttributes();
        Attr attr = document.createAttribute(NAME);
        attr.setValue(attribute.getName());
        attributes.setNamedItem(attr);

        attr = document.createAttribute(VALUE);
        attr.setValue(attribute.getValue());
        attributes.setNamedItem(attr);
    }
}
项目:XRobot    文件:LeJOSEV3LibContainer.java   
private IClasspathEntry[] createClasspath(int option) throws LeJOSEV3Exception {
       ArrayList<File> entryList = new ArrayList<File>();

    File ev3Home = LeJOSEV3Util.getEV3Home();
    String subdir = getOptionKey(option);
    LeJOSEV3Util.buildClasspath(ev3Home, subdir, entryList);

       int len = entryList.size();
       IClasspathEntry[] entryArray = new IClasspathEntry[entryList.size()];
       for (int i=0; i<len; i++)
       {
        File lib = entryList.get(i);
        File src = guessSource(lib);
        IPath lib2 = LeJOSEV3Util.toPath(lib);
        IPath src2 = (src == null) ? null : LeJOSEV3Util.toPath(src);           
        IAccessRule[] accessRules = { JavaCore.newAccessRule(new Path("**/internal/**"), IAccessRule.K_DISCOURAGED) };
        IClasspathAttribute[] attributes = {};
        entryArray[i] = JavaCore.newLibraryEntry(lib2, src2, null, accessRules, attributes, false);
       }
       return entryArray;
}
项目:test-generation    文件:BuildPathSupport.java   
public IClasspathEntry getLibraryEntry() {
    BundleInfo bundleInfo= P2Utils.findBundle(bundleId, versionRange, false);
    IPath bundleLocation= P2Utils.getBundleLocationPath(bundleInfo);
    if (bundleLocation != null) {

        IPath bundleRootLocation= getLibraryLocation(bundleInfo, bundleLocation);
        IPath srcLocation= getSourceLocation(bundleInfo);

        String javadocLocation=  "";
        if(javadoc != null)
            javadocLocation = Platform.getPreferencesService().getString(TestSpecPlugin.PLUGIN_ID, javadoc, "", null); //$NON-NLS-1$
        IClasspathAttribute[] attributes;
        if (javadocLocation.length() == 0) {
            attributes= new IClasspathAttribute[0];
        } else {
            attributes= new IClasspathAttribute[] { JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation) };
        }

        return JavaCore.newLibraryEntry(bundleRootLocation, srcLocation, null, getAccessRules(), attributes, false);
    }
    return null;
}
项目:robovm-eclipse    文件:RoboVMClasspathContainer.java   
public IClasspathEntry[] getClasspathEntries() {
    try {
     Config.Home home = RoboVMPlugin.getRoboVMHome();
     File f = home.getRtPath();
     IPath sourceAttachment = null;
     if (!home.isDev()) {
         // robovm-rt.jar. Use robovm-rt-sources.jar as source attachment.
         sourceAttachment = new Path(new File(f.getParentFile(), "robovm-rt-sources.jar").getAbsolutePath());
     } else {
         // ROBOVM_DEV_ROOT has been set and rtPath is $ROBOVM_DEV_ROOT/rt/target/robovm-rt-<version>.jar. Use
         // $ROBOVM_DEV_ROOT/rt/target/robovm-rt-<version>-sources.jar as source attachment.
         sourceAttachment = new Path(f.getAbsolutePath().replaceAll("\\.jar$", "-sources.jar"));
     }
     return new IClasspathEntry[] {
         JavaCore.newLibraryEntry(new Path(f.getAbsolutePath()), sourceAttachment, new Path(""),
                 new IAccessRule[] {}, new IClasspathAttribute[] {}, false)
     };
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:libraries    文件:IconConfigurationReader.java   
private boolean isMavenPomDerived(final IClasspathEntry classpathEntry) {
  for (final IClasspathAttribute classpathAttribute : classpathEntry.getExtraAttributes()) {
    if (Objects.equals(classpathAttribute.getName(), "maven.pomderived")) {
      return Objects.equals(classpathAttribute.getValue(), "true");
    }
  }
  return false;
}
项目:google-cloud-eclipse    文件:CreateAppEngineFlexWtpProjectTest.java   
private boolean hasNonDependencyAttribute(File jar) throws JavaModelException {
  IJavaProject javaProject = JavaCore.create(project);
  for (IClasspathEntry entry : javaProject.getRawClasspath()) {
    if (entry.getPath().toFile().equals(jar)) {
      for (IClasspathAttribute attribute : entry.getExtraAttributes()) {
        if (isNonDependencyAttribute(attribute)) {
          return true;
        }
      }
    }
  }
  return false;
}
项目:google-cloud-eclipse    文件:CreateAppEngineWtpProject.java   
private static void addJunit4ToClasspath(IProject newProject, IProgressMonitor monitor)
    throws CoreException {
  IClasspathAttribute nonDependencyAttribute =
      UpdateClasspathAttributeUtil.createNonDependencyAttribute();
  IClasspathEntry junit4Container = JavaCore.newContainerEntry(
      JUnitCore.JUNIT4_CONTAINER_PATH,
      new IAccessRule[0],
      new IClasspathAttribute[] {nonDependencyAttribute},
      false);
  ClasspathUtil.addClasspathEntry(newProject, junit4Container, monitor);
}