本文整理匯總了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;
}