本文整理汇总了Java中org.eclipse.jdt.core.IPackageFragment.getKind方法的典型用法代码示例。如果您正苦于以下问题:Java IPackageFragment.getKind方法的具体用法?Java IPackageFragment.getKind怎么用?Java IPackageFragment.getKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IPackageFragment
的用法示例。
在下文中一共展示了IPackageFragment.getKind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.eclipse.jdt.core.IPackageFragment; //导入方法依赖的package包/类
/**
* @see IBuilder#build
*/
@Override
public void build(Measure measure, ItemMeasured item) {
IPackageFragment[] packages;
ItemMeasured packageMeasured;
String packageName = "";
try {
packages = project.getPackageFragments();
for (IPackageFragment myPackage : packages) {
if ((myPackage.getKind() == IPackageFragmentRoot.K_SOURCE) && myPackage.hasChildren()) {
packageName = myPackage.isDefaultPackage() ? "(default)" : myPackage.getElementName();
packageMeasured = new ItemMeasured(packageName, item);
addClassBuilder(measure, myPackage, packageMeasured);
item.addChild(packageMeasured);
item.setMax(packageMeasured.getMax());
item.setClassWithMax(packageMeasured.getClassWithMax());
item.addValue(packageMeasured.getValue());
item.addMean(packageMeasured.getMean());
}
}
} catch (JavaModelException exception) {
logger.error(exception);
}
}
示例2: getTopLevelPackages
import org.eclipse.jdt.core.IPackageFragment; //导入方法依赖的package包/类
public static Collection<IPackageFragment> getTopLevelPackages(IJavaProject javaProject) {
Set<IPackageFragment> packages = new LinkedHashSet<>();
try {
if (javaProject == null || !javaProject.getProject().isAccessible()) {
return packages;
}
for (IPackageFragment f : javaProject.getPackageFragments()){
if (f.getKind() != IPackageFragmentRoot.K_SOURCE || f.isDefaultPackage() ) {
continue;
}
if (f.containsJavaResources() || f.getChildren().length > 1) {
packages.add(f);
}
}
} catch (CoreException e) {
e.printStackTrace();
}
return packages;
}
示例3: processPackageFragment
import org.eclipse.jdt.core.IPackageFragment; //导入方法依赖的package包/类
private void processPackageFragment(ITypeVisitor visitor,
IPackageFragment fragment, IProgressMonitor monitor)
throws JavaModelException {
switch (fragment.getKind()) {
case IPackageFragmentRoot.K_SOURCE:
final ICompilationUnit[] units = fragment.getCompilationUnits();
monitor.beginTask("", units.length); //$NON-NLS-1$
for (final ICompilationUnit unit : units) {
if (monitor.isCanceled()) {
break;
}
processCompilationUnit(visitor, unit, monitor);
monitor.worked(1);
}
break;
case IPackageFragmentRoot.K_BINARY:
final IClassFile[] classfiles = fragment.getClassFiles();
monitor.beginTask("", classfiles.length); //$NON-NLS-1$
for (final IClassFile classfile : classfiles) {
if (monitor.isCanceled()) {
break;
}
processClassFile(visitor, classfile, monitor);
monitor.worked(1);
}
break;
}
monitor.done();
}
示例4: getProjectCompilationUnits
import org.eclipse.jdt.core.IPackageFragment; //导入方法依赖的package包/类
public Set<ICompilationUnit> getProjectCompilationUnits(IJavaProject project) throws JavaModelException {
Set<ICompilationUnit> compilationUnits = new HashSet<ICompilationUnit>();
for (IPackageFragment packageFragment : project.getPackageFragments()) {
if (packageFragment.getKind() == IPackageFragmentRoot.K_SOURCE)
Collections.addAll(compilationUnits, packageFragment.getCompilationUnits());
}
return compilationUnits;
}