本文整理汇总了Java中org.eclipse.jdt.core.IClasspathEntry.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java IClasspathEntry.getPath方法的具体用法?Java IClasspathEntry.getPath怎么用?Java IClasspathEntry.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IClasspathEntry
的用法示例。
在下文中一共展示了IClasspathEntry.getPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apgasInBuildPath
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
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;
}
示例2: hasOldContainers
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
/**
* Return true if this projects uses the old-style per-library container.
*/
public static boolean hasOldContainers(IProject project) {
try {
if (!project.isAccessible() || !project.hasNature(JavaCore.NATURE_ID)) {
return false;
}
IJavaProject javaProject = JavaCore.create(project);
for (IClasspathEntry entry : javaProject.getRawClasspath()) {
IPath containerPath = entry.getPath();
if (isLibraryContainer(entry, containerPath)
&& !CloudLibraries.MASTER_CONTAINER_ID.equals(containerPath.segment(1))) {
return true;
}
}
} catch (CoreException ex) {
logger.log(Level.WARNING, "Skipping project: " + project.getName(), ex); //$NON-NLS-1$
}
return false;
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:22,代码来源:CloudToolsEclipseProjectUpdater.java
示例3: setSelection
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
@Override
public void setSelection(IClasspathEntry containerEntry) {
final IPath path = (containerEntry == null ? null
: containerEntry.getPath());
if (path == null || path.segmentCount() == 1) {
if (this.mOwnerProject != null) {
this.mLibsProjectName = this.mOwnerProject.getName();
}
} else {
this.mLibsProjectName = path.segment(1);
}
}
示例4: isPluginContainer
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
public static boolean isPluginContainer(IClasspathEntry cpe) {
if (cpe != null && cpe.getPath() != null) {
String path = cpe.getPath().toString();
return "org.eclipse.pde.core.requiredPlugins".equals(path);
}
return false;
}
示例5: getJreContainerPath
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
@VisibleForTesting
static IPath getJreContainerPath(IProject project) throws CoreException {
IJavaProject javaProject = JavaCore.create(project);
for (IClasspathEntry entry : javaProject.getRawClasspath()) {
if (JavaRuntime.JRE_CONTAINER.equals(entry.getPath().segment(0))) {
return entry.getPath();
}
}
throw new CoreException(StatusUtil.error(FlexMavenPackagedProjectStagingDelegate.class,
"Project " + project.getName() + " does not have JRE configured."));
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:12,代码来源:FlexMavenPackagedProjectStagingDelegate.java
示例6: isSwarmEntry
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
private boolean isSwarmEntry(IClasspathEntry cpe) {
//this is a quick n' very dirty detection
if (cpe.getEntryKind()==IClasspathEntry.CPE_LIBRARY) {
IPath path = cpe.getPath();
String name = path.lastSegment();
return name.startsWith("container-") && containsSwarm(path.toFile());
}
return false;
}
示例7: removeJarFilesThatDontExist
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
private void removeJarFilesThatDontExist(IProgressMonitor monitor, IProject project, IJavaProject javaProject) throws JavaModelException {
IClasspathEntry[] classPathEntries = javaProject.getRawClasspath();
List<IClasspathEntry> newClassPathEntries = new LinkedList<IClasspathEntry>();
boolean changedClassPath = false;
for (IClasspathEntry classpathEntry : classPathEntries) {
// fix jar files
if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
classpathEntry.getPath();
File classpathEntryFile = classpathEntry.getPath().toFile();
// remove JAR if it doesn't exist, only do this if the jar file is located in this project, we leave jars references from different projects
if (classpathEntryFile.getPath().endsWith(".jar") && classpathEntryFile.getPath().startsWith("/" + project.getName() + "/") && !project.getFile(classpathEntryFile.getPath().replace("/" + project.getName() + "/", "/")).exists()) {
changedClassPath = true;
if (debug)
Activator.log("libary [" + classpathEntry.getPath() + "] not found for project [ " + project.getName() + "]");
}
else {
newClassPathEntries.add(classpathEntry);
}
}
else {
newClassPathEntries.add(classpathEntry);
}
}
// we have a change to the classpath so now push the change
if (changedClassPath) {
if (newClassPathEntries.isEmpty()) {
FixProjectsUtils.setClasspath(new IClasspathEntry[0], javaProject, monitor);
}
else {
FixProjectsUtils.setClasspath(newClassPathEntries.toArray(new IClasspathEntry[newClassPathEntries.size()]), javaProject, monitor);
}
}
}
示例8: appendExternalArchiveLabel
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
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());
}
}
示例9: createResourceLoader
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
private ResourceLoader createResourceLoader(final IProject project) {
if (project != null) {
IJavaProject javaProject = JavaCore.create(project);
if (javaProject != null) {
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
try {
IClasspathEntry[] classPathEntries = javaProject.getResolvedClasspath(true);
URL[] urls = new URL[classPathEntries.length];
for (int i = 0; i < classPathEntries.length; i++) {
IClasspathEntry entry = classPathEntries[i];
IPath path = null;
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_PROJECT:
IJavaProject requiredProject = JavaCore.create((IProject) workspaceRoot.findMember(entry.getPath()));
if (requiredProject != null) {
path = workspaceRoot.findMember(requiredProject.getOutputLocation()).getLocation();
}
break;
case IClasspathEntry.CPE_SOURCE:
path = workspaceRoot.findMember(entry.getPath()).getLocation();
break;
default:
path = entry.getPath();
break;
}
if (path != null) {
urls[i] = path.toFile().toURI().toURL();
}
}
ClassLoader parentClassLoader = javaProject.getClass().getClassLoader();
URLClassLoader classLoader = new URLClassLoader(urls, parentClassLoader);
return new CustomResourceLoader(classLoader);
} catch (MalformedURLException | CoreException e) {
LOG.warn("Failed to create class loader for project " + project.getName(), e);
}
}
}
return new ResourceLoaderImpl(GeneratorSupport.class.getClassLoader());
}
示例10: createChange
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
@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();
}
示例11: addDependencies
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
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);
}
}
}