本文整理汇总了Java中org.eclipse.jdt.core.IClasspathContainer类的典型用法代码示例。如果您正苦于以下问题:Java IClasspathContainer类的具体用法?Java IClasspathContainer怎么用?Java IClasspathContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IClasspathContainer类属于org.eclipse.jdt.core包,在下文中一共展示了IClasspathContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterJREEntries
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
/**
* 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;
}
示例2: getAppEngineServerRuntimeClasspathEntries
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
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,代码行数:22,代码来源:NewMavenBasedAppEngineProjectWizardTest.java
示例3: run
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, javaProject);
LibraryClasspathContainer newContainer = attachSource(container);
if (newContainer != null) {
JavaCore.setClasspathContainer(containerPath, new IJavaProject[]{ javaProject },
new IClasspathContainer[]{ newContainer }, monitor);
serializer.saveContainer(javaProject, newContainer);
}
} catch (Exception ex) {
// it's not needed to be logged normally
logger.log(Level.FINE, Messages.getString("SourceAttachmentFailed"), ex);
}
return Status.OK_STATUS; // even if it fails, we should not display an error to the user
}
示例4: attachSource
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
@VisibleForTesting
LibraryClasspathContainer attachSource(IClasspathContainer container) throws Exception {
if (!(container instanceof LibraryClasspathContainer)) {
logger.log(Level.FINE, Messages.getString("ContainerClassUnexpected",
container.getClass().getName(), LibraryClasspathContainer.class.getName()));
return null;
}
LibraryClasspathContainer libraryClasspathContainer = (LibraryClasspathContainer) container;
IPath sourceArtifactPath = sourceArtifactPathProvider.call();
List<IClasspathEntry> newClasspathEntries = new ArrayList<>();
for (IClasspathEntry entry : libraryClasspathContainer.getClasspathEntries()) {
if (!entry.getPath().equals(libraryPath)) {
newClasspathEntries.add(entry);
} else {
newClasspathEntries.add(JavaCore.newLibraryEntry(
entry.getPath(), sourceArtifactPath, null /* sourceAttachmentRootPath */,
entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()));
}
}
return libraryClasspathContainer.copyWithNewEntries(newClasspathEntries);
}
示例5: isInsideJRE
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
public boolean isInsideJRE(IJavaElement element) {
IPackageFragmentRoot root =
(IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
if (root != null) {
try {
IClasspathEntry entry = root.getRawClasspathEntry();
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
IClasspathContainer container =
JavaCore.getClasspathContainer(entry.getPath(), root.getJavaProject());
return container != null && container.getKind() == IClasspathContainer.K_DEFAULT_SYSTEM;
}
return false;
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
return true; // include JRE in doubt
}
示例6: getPreviousSessionContainer
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
/**
* Returns a persisted container from previous session if any. Note that it is not the original
* container from previous session (i.e. it did not get serialized) but rather a summary of its
* entries recreated for CP initialization purpose. As such it should not be stored into container
* caches.
*/
public IClasspathContainer getPreviousSessionContainer(
IPath containerPath, IJavaProject project) {
Map previousContainerValues = (Map) this.previousSessionContainers.get(project);
if (previousContainerValues != null) {
IClasspathContainer previousContainer =
(IClasspathContainer) previousContainerValues.get(containerPath);
if (previousContainer != null) {
if (JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED)
// verbose_reentering_project_container_access(containerPath, project,
// previousContainer);
return previousContainer;
}
}
return null; // break cycle if none found
}
示例7: getClasspathContainer
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
public IClasspathContainer getClasspathContainer(
final IPath containerPath, final IJavaProject project) throws JavaModelException {
IClasspathContainer container = containerGet(project, containerPath);
if (container == null) {
// if (batchContainerInitializations()) {
// // avoid deep recursion while initializing container on workspace restart
// // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=60437)
// try {
// container = initializeAllContainers(project, containerPath);
// } finally {
// batchInitializationFinished();
// }
// } else {
container = initializeContainer(project, containerPath);
// containerBeingInitializedRemove(project, containerPath);
SetContainerOperation operation =
new SetContainerOperation(
containerPath, new IJavaProject[] {project}, new IClasspathContainer[] {container});
operation.runOperation(null);
// }
}
return container;
}
示例8: updateClasspath
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
public void updateClasspath(MavenProject mavenProject) {
IJavaProject javaProject = JavaCore.create(mavenProject.getProject());
if (javaProject != null) {
IClasspathEntry[] entries = getClasspath(mavenProject);
MavenClasspathContainer container = new MavenClasspathContainer(entries);
try {
JavaCore.setClasspathContainer(
new Path(MavenClasspathContainer.CONTAINER_ID),
new IJavaProject[] {javaProject},
new IClasspathContainer[] {container},
new NullProgressMonitor());
} catch (JavaModelException e) {
LOG.error(e.getMessage(), e);
}
}
}
示例9: testInitialize
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
public void testInitialize() throws Exception {
// Start with gwt-user.jar and gwt-dev-PLAT.jar on the classpath for this
// test
removeGWTRuntimeFromTestProject();
// Add the default GWT runtime to the test project (this implicitly calls
// the GWTRuntimeContainerInitializer.intialize(...) method.
IJavaProject project = getTestProject();
GWTUpdateProjectSdkCommand command = new GWTUpdateProjectSdkCommand(
project, null, GWTPreferences.getDefaultRuntime(),
UpdateType.DEFAULT_CONTAINER, null);
command.execute();
JobsUtilities.waitForIdle();
// Verify the bound classpath container
IClasspathContainer container = JavaCore.getClasspathContainer(
defaultRuntimePath, project);
assertEquals(IClasspathContainer.K_APPLICATION, container.getKind());
assertEquals(defaultRuntimePath, container.getPath());
}
示例10: replaceContainerWithClasspathEntries
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
/**
* Replace an {@link IClasspathEntry#CPE_CONTAINER} entry with the given
* container ID, with its corresponding resolved classpath entries.
*
* @param javaProject java project
* @param containerId container ID to replace
* @return true if a container was replaced
*
* @throws JavaModelException
*/
public static boolean replaceContainerWithClasspathEntries(
IJavaProject javaProject, String containerId) throws JavaModelException {
IClasspathEntry[] classpathEntries = javaProject.getRawClasspath();
int containerIndex = ClasspathUtilities.indexOfClasspathEntryContainer(
classpathEntries, containerId);
if (containerIndex != -1) {
List<IClasspathEntry> newClasspathEntries = new ArrayList<IClasspathEntry>(
Arrays.asList(classpathEntries));
IClasspathEntry classpathContainerEntry = newClasspathEntries.remove(containerIndex);
IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(
classpathContainerEntry.getPath(), javaProject);
if (classpathContainer != null) {
newClasspathEntries.addAll(containerIndex,
Arrays.asList(classpathContainer.getClasspathEntries()));
ClasspathUtilities.setRawClasspath(javaProject, newClasspathEntries);
return true;
}
}
return false;
}
示例11: initialize
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
@Override
public void initialize(IPath containerPath, final IJavaProject javaProject)
throws CoreException {
SdkClasspathContainer<T> sdkClasspathContainer = null;
final T sdk = resolveSdkFromContainerPath(containerPath, javaProject);
if (sdk != null) {
String description = getDescription(containerPath, javaProject);
sdkClasspathContainer = createClasspathContainer(containerPath, sdk,
description, javaProject);
}
// Container will be set to null if it could not be resolved which will
// result in a classpath error for the project.
JavaCore.setClasspathContainer(containerPath,
new IJavaProject[] {javaProject},
new IClasspathContainer[] {sdkClasspathContainer}, null);
}
示例12: requestClasspathContainerUpdate
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
@Override
public void requestClasspathContainerUpdate(IPath containerPath,
IJavaProject project, IClasspathContainer containerSuggestion)
throws CoreException {
SdkClasspathContainer<T> sdkClasspathContainer = null;
T sdk = resolveSdkFromContainerPath(containerPath, project);
if (sdk != null) {
String description = getDescription(containerPath, project);
sdkClasspathContainer = updateClasspathContainer(containerPath, sdk,
description, project, containerSuggestion);
}
// Container will be set to null if it could not be resolved which will
// result in a classpath error for the project.
JavaCore.setClasspathContainer(containerPath, new IJavaProject[] {project},
new IClasspathContainer[] {sdkClasspathContainer}, null);
}
示例13: resolveClasspathEntries
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
private void resolveClasspathEntries(Set<URL> urls, IWorkspaceRoot root, IClasspathEntry[] entries) throws JavaModelException {
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IPath path = entry.getPath();
if (path.segmentCount() >= 2) {
IFolder sourceFolder = root.getFolder(path);
try {
urls.add(new URL("file:///" + sourceFolder.getRawLocation().toOSString() + "/"));
} catch (MalformedURLException e) {
}
}
} else if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IPath sourcePath = entry.getPath();
covertPathToUrl(javaProject.getProject(), urls, sourcePath);
IPath sourceOutputPath = entry.getOutputLocation();
covertPathToUrl(javaProject.getProject(), urls, sourceOutputPath);
} else if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
if (entry.getPath().equals(JRClasspathContainer.ID))
continue;
IClasspathContainer cont = JavaCore.getClasspathContainer(entry.getPath(), javaProject);
resolveClasspathEntries(urls, root, cont.getClasspathEntries());
}
}
}
示例14: convertContainer
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
private static void convertContainer(IClasspathEntry entry, IJavaProject project, Map<IPath, String> oldLocationMap) {
try {
IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), project);
if (container == null) {
return;
}
IClasspathEntry[] entries= container.getClasspathEntries();
boolean hasChange= false;
for (int i= 0; i < entries.length; i++) {
IClasspathEntry curr= entries[i];
IClasspathEntry updatedEntry= getConvertedEntry(curr, project, oldLocationMap);
if (updatedEntry != null) {
entries[i]= updatedEntry;
hasChange= true;
}
}
if (hasChange) {
BuildPathSupport.requestContainerUpdate(project, container, entries);
}
} catch (CoreException e) {
// ignore
}
}
示例15: isInsideJRE
import org.eclipse.jdt.core.IClasspathContainer; //导入依赖的package包/类
public boolean isInsideJRE(IJavaElement element) {
IPackageFragmentRoot root= (IPackageFragmentRoot) element.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
if (root != null) {
try {
IClasspathEntry entry= root.getRawClasspathEntry();
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
IClasspathContainer container= JavaCore.getClasspathContainer(entry.getPath(), root.getJavaProject());
return container != null && container.getKind() == IClasspathContainer.K_DEFAULT_SYSTEM;
}
return false;
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
return true; // include JRE in doubt
}