当前位置: 首页>>代码示例>>Java>>正文


Java IClasspathEntry.CPE_CONTAINER属性代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IClasspathEntry.CPE_CONTAINER属性的典型用法代码示例。如果您正苦于以下问题:Java IClasspathEntry.CPE_CONTAINER属性的具体用法?Java IClasspathEntry.CPE_CONTAINER怎么用?Java IClasspathEntry.CPE_CONTAINER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.core.IClasspathEntry的用法示例。


在下文中一共展示了IClasspathEntry.CPE_CONTAINER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProjectClassPath

public static void getProjectClassPath(IJavaProject project, List<File> dst) throws Exception {
	IRuntimeClasspathEntry [] rentries = JavaRuntime.computeUnresolvedRuntimeClasspath(project);
	for (IRuntimeClasspathEntry entry : rentries) {
		switch (entry.getType()) {
		case IClasspathEntry.CPE_SOURCE: 
			break;
		case IClasspathEntry.CPE_PROJECT:
			break;
		case IClasspathEntry.CPE_LIBRARY:
			break;
		case IClasspathEntry.CPE_VARIABLE:
			// JRE like entries
			IRuntimeClasspathEntry [] variableEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			break;
		case IClasspathEntry.CPE_CONTAINER:
			IRuntimeClasspathEntry [] containerEntries  = JavaRuntime.resolveRuntimeClasspathEntry(entry, project);
			for (IRuntimeClasspathEntry containerentry : containerEntries) {
				dst.add(new File (containerentry.getLocation()));
			}
			break;
		default:
			throw new Exception("unsupported classpath entry "+entry);
		}
	}
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:25,代码来源:TestResourceGeneration.java

示例2: execute

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  final IPath containerPath = new Path(Initializer.APGAS_CONTAINER_ID);
  try {
    final IJavaProject javaProject = JavaCore
        .create(((IAdaptable) ((IStructuredSelection) HandlerUtil
            .getCurrentSelection(event)).getFirstElement())
                .getAdapter(IProject.class));
    final IClasspathEntry[] entries = javaProject.getRawClasspath();
    for (int i = 0; i < entries.length; i++) {
      if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER
          && entries[i].getPath().equals(containerPath)) {
        return null;
      }
    }
    final IClasspathEntry[] cp = new IClasspathEntry[entries.length + 1];
    System.arraycopy(entries, 0, cp, 0, entries.length);
    cp[entries.length] = JavaCore.newContainerEntry(containerPath);
    javaProject.setRawClasspath(cp, new NullProgressMonitor());
  } catch (final Exception e) {
    throw new ExecutionException(e.toString(), e);
  }
  return null;
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:24,代码来源:Handler.java

示例3: apgasInBuildPath

private boolean apgasInBuildPath(IJavaProject javaProject) {
  if (javaProject == null) {
    return false;
  }

  IClasspathEntry[] entries = null;
  try {
    entries = javaProject.getRawClasspath();
  } catch (final JavaModelException e) {
    return false;
  }
  for (final IClasspathEntry entry : entries) {
    final int kind = entry.getEntryKind();
    final IPath path = entry.getPath();
    if (kind == IClasspathEntry.CPE_CONTAINER
        && path.equals(new Path(Initializer.APGAS_CONTAINER_ID))) {
      return true;
    }

  }
  return false;
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:22,代码来源:APGASQuickfixProcessor.java

示例4: filterJREEntries

/**
 * Remove all JRE runtime entries from the given set
 *
 * @param scope
 *          set to filter
 * @return filtered set without JRE runtime entries
 */
public static Set<IPackageFragmentRoot> filterJREEntries(
    Collection<IPackageFragmentRoot> scope) throws JavaModelException {
  final Set<IPackageFragmentRoot> filtered = new HashSet<IPackageFragmentRoot>();
  for (final IPackageFragmentRoot root : scope) {
    final IClasspathEntry entry = root.getRawClasspathEntry();
    switch (entry.getEntryKind()) {
    case IClasspathEntry.CPE_SOURCE:
    case IClasspathEntry.CPE_LIBRARY:
    case IClasspathEntry.CPE_VARIABLE:
      filtered.add(root);
      break;
    case IClasspathEntry.CPE_CONTAINER:
      IClasspathContainer container = JavaCore.getClasspathContainer(
          entry.getPath(), root.getJavaProject());
      if (container != null
          && container.getKind() == IClasspathContainer.K_APPLICATION) {
        filtered.add(root);
      }
      break;
    }
  }
  return filtered;
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:30,代码来源:ScopeUtils.java

示例5: getAppEngineServerRuntimeClasspathEntries

static IClasspathEntry[] getAppEngineServerRuntimeClasspathEntries(IProject project) {
  IJavaProject javaProject = JavaCore.create(project);
  IPath containerPath = new Path(
      "org.eclipse.jst.server.core.container/com.google.cloud.tools.eclipse.appengine.standard.runtimeClasspathProvider");
  try {
    for (IClasspathEntry entry : javaProject.getRawClasspath()) {
      if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER
          && containerPath.isPrefixOf(entry.getPath())) {
        // resolve and return the entries
        IClasspathContainer container =
            JavaCore.getClasspathContainer(entry.getPath(), javaProject);
        return container.getClasspathEntries();
      }
    }
  } catch (JavaModelException ex) {
    fail(ex.toString());
    /* NOTREACHED */
  }
  fail("AppEngine Server Runtime classpath container not found");
  return null;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:21,代码来源:NewMavenBasedAppEngineProjectWizardTest.java

示例6: fixMissingJavaRuntime

/**
 * Sometimes the project configuration is corrupt and a Java runtime is not on the classpath
 * @param monitor
 * @param javaProject
 * @throws JavaModelException
 */
private void fixMissingJavaRuntime(IProgressMonitor monitor, IJavaProject javaProject) throws JavaModelException {
	
	if (!javaProject.getProject().getName().equals("config")) {
		IClasspathEntry[] classPathEntries = javaProject.getRawClasspath();
		boolean found = false;
		for (IClasspathEntry classpathEntry : classPathEntries) {
			// fix missing runtime
			if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
				if (classpathEntry.getPath().toString().startsWith("org.eclipse.jdt.launching.JRE_CONTAINER")) {
					found = true;
					break;
				}
			}
		}
		
		if (!found) {
			IClasspathEntry entry = JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER"),
					false);
			Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>(Arrays.asList(classPathEntries));
			entries.add(entry);
			FixProjectsUtils.setClasspath(entries.toArray(new IClasspathEntry[entries.size()]), javaProject,
					monitor);
		}
	}
}
 
开发者ID:SAP,项目名称:hybris-commerce-eclipse-plugin,代码行数:31,代码来源:Importer.java

示例7: getProjectView

/**
 * Convert an Eclipse JDT project into an IntelliJ project view
 */
public static ProjectView getProjectView(IProject project)
    throws BackingStoreException, JavaModelException {
  com.google.devtools.bazel.e4b.projectviews.Builder builder = ProjectView.builder();
  IScopeContext projectScope = new ProjectScope(project);
  Preferences projectNode = projectScope.getNode(Activator.PLUGIN_ID);
  for (String s : projectNode.keys()) {
    if (s.startsWith("buildArgs")) {
      builder.addBuildFlag(projectNode.get(s, ""));
    } else if (s.startsWith("target")) {
      builder.addTarget(projectNode.get(s, ""));
    }
  }

  IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
  for (IClasspathEntry entry : ((IJavaProject) project).getRawClasspath()) {
    switch (entry.getEntryKind()) {
      case IClasspathEntry.CPE_SOURCE:
        IResource res = root.findMember(entry.getPath());
        if (res != null) {
          builder.addDirectory(res.getProjectRelativePath().removeFirstSegments(1).toOSString());
        }
        break;
      case IClasspathEntry.CPE_CONTAINER:
        String path = entry.getPath().toOSString();
        if (path.startsWith(STANDARD_VM_CONTAINER_PREFIX)) {
          builder.setJavaLanguageLevel(
              Integer.parseInt(path.substring(STANDARD_VM_CONTAINER_PREFIX.length())));
        }
        break;
    }
  }
  return builder.build();
}
 
开发者ID:bazelbuild,项目名称:eclipse,代码行数:36,代码来源:BazelProjectSupport.java

示例8: hasWtpClasspathContainers

private static boolean hasWtpClasspathContainers(IProject project) throws JavaModelException {
  boolean seenWebContainer = false;
  IJavaProject javaProject = JavaCore.create(project);
  for (IClasspathEntry entry : javaProject.getRawClasspath()) {
    if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
      if (entry.getPath().equals(new Path("org.eclipse.jst.j2ee.internal.web.container"))) {
        seenWebContainer = true;
      }
    }
  }
  return seenWebContainer;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:12,代码来源:FacetUtilTest.java

示例9: setContainerClasspathExternalAnnotationsPath

/**
 * Set classpath for external annotations.
 *
 * @param classpath the classpath
 * @param annotationPath the path of the annotation
 * @param startsWith if present the annotation path if added only if the classpath entry starts with the given
 *            prefix, if empty it is added to every classpath entry
 */
private void setContainerClasspathExternalAnnotationsPath(final IClasspathDescriptor classpath,
        final String annotationPath, final Optional<String> startsWith) {
    for (final IClasspathEntryDescriptor cpEntry : classpath.getEntryDescriptors()) {
        if (cpEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
            if (startsWith.isPresent()) {
                if (cpEntry.getPath().toString().startsWith(startsWith.get())) {
                    setExternalAnnotationsPath(cpEntry, annotationPath);
                }
            } else {
                setExternalAnnotationsPath(cpEntry, annotationPath);
            }
        }
    }
}
 
开发者ID:lastnpe,项目名称:eclipse-external-annotations-m2e-plugin,代码行数:22,代码来源:ClasspathConfigurator.java

示例10: appendExternalArchiveLabel

private void appendExternalArchiveLabel(IPackageFragmentRoot root, long flags) {
	IPath path;
	IClasspathEntry classpathEntry= null;
	try {
		classpathEntry= JavaModelUtil.getClasspathEntry(root);
		IPath rawPath= classpathEntry.getPath();
		if (classpathEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && !rawPath.isAbsolute()) {
			path= rawPath;
		} else {
			path= root.getPath();
		}
	} catch (JavaModelException e) {
		path= root.getPath();
	}
	if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
		int segments= path.segmentCount();
		if (segments > 0) {
			fBuilder.append(path.segment(segments - 1));
			if (segments > 1 || path.getDevice() != null) {
				fBuilder.append(JavaElementLabels.CONCAT_STRING);
				fBuilder.append(path.removeLastSegments(1).toOSString());
			}
			if (classpathEntry != null) {
				IClasspathEntry referencingEntry= classpathEntry.getReferencingEntry();
				if (referencingEntry != null) {
					fBuilder.append(NLS.bind(" (from {0} of {1})", new Object[] { Name.CLASS_PATH.toString(), referencingEntry.getPath().lastSegment() }));
				}
			}
		} else {
			fBuilder.append(path.toOSString());
		}
	} else {
		fBuilder.append(path.toOSString());
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:35,代码来源:JavaElementLabelComposer.java

示例11: createChange

@Override
public Change createChange(IProgressMonitor monitor) throws CoreException {
  if (monitor == null) {
    monitor = new NullProgressMonitor();
  }
  monitor.beginTask("Adding APGAS library...", 1);
  try {
    IClasspathEntry entry = null;
    entry = JavaCore.newContainerEntry(new Path(
        Initializer.APGAS_CONTAINER_ID));
    final IClasspathEntry[] oldEntries = fProject.getRawClasspath();
    final ArrayList<IClasspathEntry> newEntries = new ArrayList<IClasspathEntry>(
        oldEntries.length + 1);
    boolean added = false;
    for (int i = 0; i < oldEntries.length; i++) {
      IClasspathEntry curr = oldEntries[i];
      if (curr.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
        final IPath path = curr.getPath();
        if (path.equals(entry.getPath())) {
          return new NullChange(); // already on build path
        } else if (path.matchingFirstSegments(entry.getPath()) > 0) {
          if (!added) {
            curr = entry; // replace
            added = true;
          } else {
            curr = null;
          }
        }
      } else if (curr.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {

      }
      if (curr != null) {
        newEntries.add(curr);
      }
    }
    if (!added) {
      newEntries.add(entry);
    }

    final IClasspathEntry[] newCPEntries = newEntries
        .toArray(new IClasspathEntry[newEntries.size()]);
    final Change newClasspathChange = newClasspathChange(fProject,
        newCPEntries, fProject.getOutputLocation());
    if (newClasspathChange != null) {
      return newClasspathChange;
    }
  } finally {
    monitor.done();
  }
  return new NullChange();
}
 
开发者ID:x10-lang,项目名称:apgas,代码行数:51,代码来源:APGASClasspathFixProposal.java

示例12: addDependencies

private void addDependencies(final IProgressMonitor monitor, final ICanceler canceler, final WorkspaceBuilder builder)
    throws JavaModelException,
      InterruptedException {
  for (final IJavaProject javaProject : this.model.getJavaProjects()) {
    final String message = MessageFormat.format("scanne dependencies for project {0}", javaProject.getElementName()); //$NON-NLS-1$
    this.logger.log(Level.INFO, message);
    monitor.subTask(message);
    final Project project = builder.getProject(javaProject.getPath().toPortableString());
    if (project == null) {
      continue;
    }
    final Set<ILibrary> libraries = new HashSet<>();
    ClasspathCollector.collect(canceler, libraries, project);
    for (final IClasspathEntry classpathEntry : javaProject.getRawClasspath()) {
      if (canceler.isCanceled()) {
        throw new InterruptedException();
      }
      final int entryKind = classpathEntry.getEntryKind();
      switch (entryKind) {
        case IClasspathEntry.CPE_LIBRARY:
        case IClasspathEntry.CPE_PROJECT: {
          final org.eclipse.core.runtime.IPath path = classpathEntry.getPath();
          final Library library = builder.getLibrary(path.toPortableString());
          if (library == null || libraries.contains(library)) {
            continue;
          }
          ClasspathCollector.collect(canceler, libraries, library);
          if (libraries.contains(project)) {
            final String submessage =
                MessageFormat.format("dependencies for project {0} builds cycle over library {1}", //$NON-NLS-1$
                    javaProject.getElementName(), library.getName());
            this.logger.log(Level.ERROR, submessage);
            this.logger.log(Level.ERROR, ObjectUtilities.toString(library));
            throw new JavaModelException(new Exception(submessage), IStatus.ERROR);
          }
          libraries.add(library);
          project.getDependencies().add(new Dependency(library, classpathEntry.isExported()));
          break;
        }
        case IClasspathEntry.CPE_CONTAINER: {
          break;
        }
        case IClasspathEntry.CPE_SOURCE: {
          break;
        }
        case IClasspathEntry.CPE_VARIABLE: {
          break;
        }
        default:
          break;
      }
      project.setClasspath(libraries);
    }
  }
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:55,代码来源:WorkspaceDependenciesInvestigator.java

示例13: isLibraryContainer

private static boolean isLibraryContainer(IClasspathEntry entry, IPath containerPath) {
  return entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER
      && containerPath.segmentCount() == 2
      && LibraryClasspathContainer.CONTAINER_PATH_PREFIX
          .equals(containerPath.segment(0));
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:6,代码来源:CloudToolsEclipseProjectUpdater.java

示例14: addProjectEntries

protected void addProjectEntries(Set<IRuntimeClasspathEntry> resolved, IPath path, int scope, String classifier,
      ILaunchConfiguration launchConfiguration, final IProgressMonitor monitor) throws CoreException {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IProject project = root.getProject(path.segment(0));

    IMavenProjectFacade projectFacade = projectManager.create(project, monitor);
    if(projectFacade == null) {
      return;
    }

    ResolverConfiguration configuration = projectFacade.getResolverConfiguration();
    if(configuration == null) {
      return;
    }

    IJavaProject javaProject = JavaCore.create(project);

    boolean projectResolved = false;

    for(IClasspathEntry entry : javaProject.getRawClasspath()) {
      IRuntimeClasspathEntry rce = null;
      switch(entry.getEntryKind()) {
        case IClasspathEntry.CPE_SOURCE:
          if(!projectResolved) {

            IMavenClassifierManager mavenClassifierManager = MavenJdtPlugin.getDefault().getMavenClassifierManager();
            IClassifierClasspathProvider classifierClasspathProvider = mavenClassifierManager
                .getClassifierClasspathProvider(projectFacade, classifier);

            if(IClasspathManager.CLASSPATH_TEST == scope) {
              classifierClasspathProvider.setTestClasspath(resolved, projectFacade, monitor);
            } else {
              classifierClasspathProvider.setRuntimeClasspath(resolved, projectFacade, monitor);
            }

            projectResolved = true;
          }
          break;
        case IClasspathEntry.CPE_CONTAINER:
          IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), javaProject);
          if(container != null && !MavenClasspathHelpers.isMaven2ClasspathContainer(entry.getPath())) {
            switch(container.getKind()) {
              case IClasspathContainer.K_APPLICATION:
                rce = JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(),
                    IRuntimeClasspathEntry.USER_CLASSES, javaProject);
                break;
//                case IClasspathContainer.K_DEFAULT_SYSTEM:
//                  unresolved.add(JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), IRuntimeClasspathEntry.STANDARD_CLASSES, javaProject));
//                  break;
//                case IClasspathContainer.K_SYSTEM:
//                  unresolved.add(JavaRuntime.newRuntimeContainerClasspathEntry(container.getPath(), IRuntimeClasspathEntry.BOOTSTRAP_CLASSES, javaProject));
//                  break;
            }
          }
          break;
        case IClasspathEntry.CPE_LIBRARY:
          rce = JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath());
          break;
        case IClasspathEntry.CPE_VARIABLE:
          if(!JavaRuntime.JRELIB_VARIABLE.equals(entry.getPath().segment(0))) {
            rce = JavaRuntime.newVariableRuntimeClasspathEntry(entry.getPath());
          }
          break;
        case IClasspathEntry.CPE_PROJECT:
          IProject res = root.getProject(entry.getPath().segment(0));
          if(res != null) {
            IJavaProject otherProject = JavaCore.create(res);
            if(otherProject != null) {
              rce = JavaRuntime.newDefaultProjectClasspathEntry(otherProject);
            }
          }
          break;
        default:
          break;
      }
      if(rce != null) {
        addStandardClasspathEntries(resolved, rce, launchConfiguration);
      }
    }
  }
 
开发者ID:fbricon,项目名称:wildfly-hive,代码行数:80,代码来源:MavenRuntimeClasspathProvider.java

示例15: getWorkspaceInfo

private String getWorkspaceInfo() {
	StringBuilder b = new StringBuilder();
	b.append("Projects:\n");
	for (IProject project : getWorkspaceRoot().getProjects()) {
		b.append(project.getName()).append(": ").append(project.getLocation().toOSString()).append('\n');
		if (ProjectUtils.isJavaProject(project)) {
			IJavaProject javaProject = JavaCore.create(project);
			try {
				b.append("  resolved classpath:\n");
				IClasspathEntry[] cpEntries = javaProject.getRawClasspath();
				for (IClasspathEntry cpe : cpEntries) {
					b.append("  ").append(cpe.getPath().toString()).append('\n');
					if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
						IPackageFragmentRoot[] roots = javaProject.findPackageFragmentRoots(cpe);
						for (IPackageFragmentRoot root : roots) {
							b.append("    ").append(root.getPath().toString()).append('\n');
						}
					}
				}
			} catch (CoreException e) {
				// ignore
			}
		} else {
			b.append("  non-Java project\n");
		}
	}
	b.append("Java Runtimes:\n");
	IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
	b.append("  default: ");
	if (defaultVMInstall != null) {
		b.append(defaultVMInstall.getInstallLocation().toString());
	} else {
		b.append("-");
	}
	IExecutionEnvironmentsManager eem = JavaRuntime.getExecutionEnvironmentsManager();
	for (IExecutionEnvironment ee : eem.getExecutionEnvironments()) {
		IVMInstall[] vms = ee.getCompatibleVMs();
		b.append("  ").append(ee.getDescription()).append(": ");
		if (vms.length > 0) {
			b.append(vms[0].getInstallLocation().toString());
		} else {
			b.append("-");
		}
		b.append("\n");
	}
	return b.toString();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:47,代码来源:ProjectsManager.java


注:本文中的org.eclipse.jdt.core.IClasspathEntry.CPE_CONTAINER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。