本文整理汇总了Java中org.eclipse.jdt.core.IClasspathEntry.getEntryKind方法的典型用法代码示例。如果您正苦于以下问题:Java IClasspathEntry.getEntryKind方法的具体用法?Java IClasspathEntry.getEntryKind怎么用?Java IClasspathEntry.getEntryKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IClasspathEntry
的用法示例。
在下文中一共展示了IClasspathEntry.getEntryKind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilteredSourceFolders
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
/**
* @param projectName
* @return the direct child folders of the project
* @throws CoreException
*/
public static List<String> getFilteredSourceFolders(String projectName, String[] excludes) throws CoreException {
List<String> ret = new ArrayList<String>();
IJavaProject javaProject = (IJavaProject) JavaCore.create(getProject(projectName));
IClasspathEntry[] entries = javaProject.getRawClasspath();
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IPath path = entry.getPath().makeRelativeTo(new Path(projectName));
boolean isExcluded = false;
for (int j = 0; j < excludes.length; j++) {
if (excludes[j].equalsIgnoreCase(path.toString())) {
isExcluded = true;
break;
}
}
if (!isExcluded) {
String p = path.toString();
ret.add(p);
}
}
}
return ret;
}
示例2: 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;
}
示例3: isSourcePath
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
private boolean isSourcePath(String path) throws JavaModelException, BackingStoreException {
Path pp = new File(instance.getWorkspaceRoot().toString() + File.separator + path).toPath();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
for (IClasspathEntry entry : project.getRawClasspath()) {
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IResource res = root.findMember(entry.getPath());
if (res != null) {
String file = res.getLocation().toOSString();
if (!file.isEmpty() && pp.startsWith(file)) {
IPath[] inclusionPatterns = entry.getInclusionPatterns();
if (!matchPatterns(pp, entry.getExclusionPatterns()) && (inclusionPatterns == null
|| inclusionPatterns.length == 0 || matchPatterns(pp, inclusionPatterns))) {
return true;
}
}
}
}
}
return false;
}
示例4: filterJREEntries
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的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;
}
示例5: removeFromClassPath
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
public static void removeFromClassPath(IResource res, int type, IJavaProject javaProject, IProgressMonitor monitor) throws JavaModelException
{
List<IClasspathEntry> entries = new LinkedList<IClasspathEntry>(Arrays.asList(javaProject.getRawClasspath()));
ListIterator<IClasspathEntry> iterator = entries.listIterator();
boolean changed = false;
while (iterator.hasNext())
{
IClasspathEntry entry = iterator.next();
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
{
if (res.getFullPath().equals(entry.getPath()))
{
changed = true;
if (debug)
Activator.log("Removing src path [" + res.getFullPath() + "] for project [" + javaProject.getProject().getName() + "]");
iterator.remove();
}
}
}
if (changed) {
setClasspath(entries.toArray(new IClasspathEntry[entries.size()]), javaProject, monitor);
}
}
示例6: getAppEngineServerRuntimeClasspathEntries
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的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
示例7: addMavenClasspathEntries
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
private void addMavenClasspathEntries(Set<IRuntimeClasspathEntry> resolved,
IRuntimeClasspathEntry runtimeClasspathEntry, ILaunchConfiguration configuration, int scope,
IProgressMonitor monitor) throws CoreException {
IJavaProject javaProject = JavaRuntime.getJavaProject(configuration);
MavenJdtPlugin plugin = MavenJdtPlugin.getDefault();
IClasspathManager buildpathManager = plugin.getBuildpathManager();
IClasspathEntry[] cp = buildpathManager.getClasspath(javaProject.getProject(), scope, false, monitor);
for(IClasspathEntry entry : cp) {
switch(entry.getEntryKind()) {
case IClasspathEntry.CPE_PROJECT:
addProjectEntries(resolved, entry.getPath(), scope, getArtifactClassifier(entry), configuration, monitor);
break;
case IClasspathEntry.CPE_LIBRARY:
resolved.add(JavaRuntime.newArchiveRuntimeClasspathEntry(entry.getPath()));
break;
// case IClasspathEntry.CPE_SOURCE:
// resolved.add(newSourceClasspathEntry(javaProject, cp[i]));
// break;
}
}
}
示例8: isClasspathEntryForJar
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
/**
*
* @param javaProject
* @param jar
* @return
* @throws JavaModelException
*/
private boolean isClasspathEntryForJar(IJavaProject javaProject, IResource jar) throws JavaModelException
{
IClasspathEntry[] classPathEntries = javaProject.getRawClasspath();
if (classPathEntries != null) {
for (IClasspathEntry classpathEntry : classPathEntries) {
// fix jar files
if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
if (classpathEntry.getPath().equals(jar.getFullPath())) {
return true;
}
}
}
}
return false;
}
示例9: getProjectView
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
/**
* 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();
}
示例10: 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());
}
}
示例11: fixTestSourceDirectorySettings
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
private void fixTestSourceDirectorySettings(IProject newProject, IProgressMonitor monitor)
throws CoreException {
// 1. Fix the output folder of "src/test/java".
IPath testSourcePath = newProject.getFolder("src/test/java").getFullPath();
IJavaProject javaProject = JavaCore.create(newProject);
IClasspathEntry[] entries = javaProject.getRawClasspath();
for (int i = 0; i < entries.length; i++) {
IClasspathEntry entry = entries[i];
if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE
&& entry.getPath().equals(testSourcePath)
&& entry.getOutputLocation() == null) { // Default output location?
IPath oldOutputPath = javaProject.getOutputLocation();
IPath newOutputPath = oldOutputPath.removeLastSegments(1).append("test-classes");
entries[i] = JavaCore.newSourceEntry(testSourcePath, ClasspathEntry.INCLUDE_ALL,
ClasspathEntry.EXCLUDE_NONE, newOutputPath);
javaProject.setRawClasspath(entries, monitor);
break;
}
}
// 2. Remove "src/test/java" from the Web Deployment Assembly sources.
deployAssemblyEntryRemoveJob =
new DeployAssemblyEntryRemoveJob(newProject, new Path("src/test/java"));
deployAssemblyEntryRemoveJob.setSystem(true);
deployAssemblyEntryRemoveJob.schedule();
}
示例12: hasWtpClasspathContainers
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
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;
}
示例13: isOnClasspath
import org.eclipse.jdt.core.IClasspathEntry; //导入方法依赖的package包/类
/**
* Using IJavaProject.isOnClasspath() is not accurate
* @throws JavaModelException
*/
private static boolean isOnClasspath(IResource resource, IJavaProject javaProject, int type) throws JavaModelException
{
for (IClasspathEntry classPath : javaProject.getRawClasspath())
{
if (classPath.getEntryKind() == type)
{
if (resource.getFullPath().equals(classPath.getPath()))
{
return true;
}
}
}
return false;
}
示例14: 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());
}
示例15: 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);
}
}
}