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


Java IClasspathContainer.getKind方法代码示例

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


在下文中一共展示了IClasspathContainer.getKind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:31,代码来源:ScopeUtils.java

示例2: 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
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:JavaSearchScopeFactory.java

示例3: 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
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:JavaSearchScopeFactory.java

示例4: CPUserLibraryElement

import org.eclipse.jdt.core.IClasspathContainer; //导入方法依赖的package包/类
public CPUserLibraryElement(String name, IClasspathContainer container, IJavaProject project) {
	fName= name;
	fChildren= new ArrayList<CPListElement>();
	if (container != null) {
		IClasspathEntry[] entries= container.getClasspathEntries();
		CPListElement[] res= new CPListElement[entries.length];
		for (int i= 0; i < res.length; i++) {
			IClasspathEntry curr= entries[i];
			CPListElement elem= CPListElement.createFromExisting(this, curr, project);
			//elem.setAttribute(CPListElement.SOURCEATTACHMENT, curr.getSourceAttachmentPath());
			//elem.setAttribute(CPListElement.JAVADOC, JavaUI.getLibraryJavadocLocation(curr.getPath()));
			fChildren.add(elem);
		}
		fIsSystemLibrary= container.getKind() == IClasspathContainer.K_SYSTEM;
	} else {
		fIsSystemLibrary= false;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:CPUserLibraryElement.java

示例5: hasChanges

import org.eclipse.jdt.core.IClasspathContainer; //导入方法依赖的package包/类
public boolean hasChanges(IClasspathContainer oldContainer) {
	if (oldContainer == null || (oldContainer.getKind() == IClasspathContainer.K_SYSTEM) != fIsSystemLibrary) {
		return true;
	}
	IClasspathEntry[] oldEntries= oldContainer.getClasspathEntries();
	if (fChildren.size() != oldEntries.length) {
		return true;
	}
	for (int i= 0; i < oldEntries.length; i++) {
		CPListElement child= fChildren.get(i);
		if (!child.getClasspathEntry().equals(oldEntries[i])) {
			return true;
		}
	}
	return false;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:CPUserLibraryElement.java

示例6: removeSystemContainers

import org.eclipse.jdt.core.IClasspathContainer; //导入方法依赖的package包/类
private void removeSystemContainers(List<IClasspathEntry> resolvedClasspath) throws JavaModelException {
	IClasspathEntry[] rawClasspath = project.getRawClasspath();
	
	for (IClasspathEntry classpathEntry : rawClasspath) {
		if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
			IClasspathContainer container = JavaCore.getClasspathContainer(classpathEntry.getPath(), project);
			if (container.getKind() != IClasspathContainer.K_APPLICATION) {
				for (IClasspathEntry containerEntry : container.getClasspathEntries()) {
					resolvedClasspath.remove(containerEntry);
				}
			}
		}
	}
}
 
开发者ID:tsvetan-stoyanov,项目名称:launchpi,代码行数:15,代码来源:ClasspathResolver.java

示例7: addProjectEntries

import org.eclipse.jdt.core.IClasspathContainer; //导入方法依赖的package包/类
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,代码行数:81,代码来源:MavenRuntimeClasspathProvider.java

示例8: getChildProjects

import org.eclipse.jdt.core.IClasspathContainer; //导入方法依赖的package包/类
private void getChildProjects(IJavaProject jproject, Vector projects,
        boolean exportedOnly) {

    IClasspathEntry[] cpes = jproject.readRawClasspath();
    if (cpes != null) {
        for (int i = 0; i < cpes.length; i++) {
            IClasspathEntry cpe = JavaCore
                    .getResolvedClasspathEntry(cpes[i]);
            if (cpe == null) {
                System.err.println("Error: cpes[" + i + "]=" + cpes[i]
                        + " does not resolve");
                continue;
            }
            int kind = cpe.getEntryKind();
            String name = relPath(cpe.getPath());
            if (kind == IClasspathEntry.CPE_CONTAINER) {
                try {
                    IClasspathContainer container = JavaCore
                            .getClasspathContainer(cpe.getPath(), jproject);
                    if ((container.getKind() == IClasspathContainer.K_APPLICATION)
                            || (container.getKind() == IClasspathContainer.K_SYSTEM)) {
                        IClasspathEntry[] cpes2 = container
                                .getClasspathEntries();
                        for (int j = 0; j < cpes2.length; j++) {
                            IClasspathEntry cpe2 = cpes2[j];
                            int kind2 = cpe2.getEntryKind();
                            String name2 = relPath(cpe2.getPath());
                            if (name2 == null) {
                                System.err
                                        .println("invalid classpath entry: "
                                                + cpe2.toString());
                            } else {
                                if (kind2 == IClasspathEntry.CPE_PROJECT) {
                                    if (!exportedOnly || cpe2.isExported()) {
                                        if (!projects.contains(name2)) {
                                            IJavaProject jChildProject2 = jproject
                                                    .getJavaModel()
                                                    .getJavaProject(name2);
                                            projects.add(jChildProject2);
                                            getChildProjects(
                                                    jChildProject2,
                                                    projects, true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                } catch (JavaModelException e) {
                }
            } else if (kind == IClasspathEntry.CPE_PROJECT) {
                if (name == null) {
                    System.err.println("invalid classpath entry: "
                            + cpe.toString());
                } else {
                    if (!exportedOnly || cpe.isExported()) {
                        if (!projects.contains(name)) {
                            IJavaProject jChildProject = jproject
                                    .getJavaModel().getJavaProject(name);
                            projects.add(jChildProject);
                            getChildProjects(jChildProject, projects, true);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:69,代码来源:BuildFatJar.java

示例9: getChildProjects

import org.eclipse.jdt.core.IClasspathContainer; //导入方法依赖的package包/类
public void getChildProjects(Vector projects, boolean exportedOnly) {

        IClasspathEntry[] cpes = this.getRawClasspathEntries();
        if (cpes != null) {
            for (int i = 0; i < cpes.length; i++) {
                IClasspathEntry cpe = JavaCore
                        .getResolvedClasspathEntry(cpes[i]);
                if (cpe == null) {
                    System.err.println("Error: cpes[" + i + "]=" + cpes[i]
                            + " does not resolve");
                    continue;
                }
                int kind = cpe.getEntryKind();
                String name = relPath(cpe.getPath());
                if (kind == IClasspathEntry.CPE_CONTAINER) {
                    try {
                        IClasspathContainer container = JavaCore
                                .getClasspathContainer(cpe.getPath(), jproject);
                        if ((container.getKind() == IClasspathContainer.K_APPLICATION)
                                || (container.getKind() == IClasspathContainer.K_SYSTEM)) {
                            IClasspathEntry[] cpes2 = container
                                    .getClasspathEntries();
                            for (int j = 0; j < cpes2.length; j++) {
                                IClasspathEntry cpe2 = cpes2[j];
                                int kind2 = cpe2.getEntryKind();
                                String name2 = relPath(cpe2.getPath());
                                if (name2 == null) {
                                    System.err
                                            .println("invalid classpath entry: "
                                                    + cpe2.toString());
                                } else {
                                    if (kind2 == IClasspathEntry.CPE_PROJECT) {
                                        if (!exportedOnly || cpe2.isExported()) {
                                            if (!projects.contains(name2)) {
                                                IJavaProject jChildProject2 = jproject
                                                        .getJavaModel()
                                                        .getJavaProject(name2);
                                                JProjectConfiguration jpcChild2 = new JProjectConfiguration(
                                                        jChildProject2, null);
                                                projects.add(jpcChild2);
                                                jpcChild2.getChildProjects(
                                                        projects, true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } catch (JavaModelException e) {
                    }
                } else if (kind == IClasspathEntry.CPE_PROJECT) {
                    if (name == null) {
                        System.err.println("invalid classpath entry: "
                                + cpe.toString());
                    } else {
                        if (!exportedOnly || cpe.isExported()) {
                            if (!projects.contains(name)) {
                                IJavaProject jChildProject = jproject
                                        .getJavaModel().getJavaProject(name);
                                JProjectConfiguration jpcChild = new JProjectConfiguration(
                                        jChildProject, null);
                                projects.add(jpcChild);
                                jpcChild.getChildProjects(projects, true);
                            }
                        }
                    }
                }
            }
        }
    }
 
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:71,代码来源:JProjectConfiguration.java


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