本文整理汇总了Java中org.eclipse.jdt.core.IPackageFragmentRoot.close方法的典型用法代码示例。如果您正苦于以下问题:Java IPackageFragmentRoot.close方法的具体用法?Java IPackageFragmentRoot.close怎么用?Java IPackageFragmentRoot.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IPackageFragmentRoot
的用法示例。
在下文中一共展示了IPackageFragmentRoot.close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attachSource
import org.eclipse.jdt.core.IPackageFragmentRoot; //导入方法依赖的package包/类
public static void attachSource(final IPackageFragmentRoot fragment, final IPath newSourcePath,
IProgressMonitor monitor) {
try {
if (fragment == null || fragment.getKind() != IPackageFragmentRoot.K_BINARY) {
return;
}
if (!Objects.equals(fragment.getSourceAttachmentPath(), newSourcePath)) {
// would be so cool if it refreshed the UI automatically
fragment.attachSource(newSourcePath, null, monitor);
// close the root so that source attachment cache is flushed. Else UI
// won't update
fragment.close();
// we have to manually fire a delta to notify the UI about the source
// attachment.
JavaModelManager manager = JavaModelManager.getJavaModelManager();
JavaElementDelta attachedSourceDelta = new JavaElementDelta(fragment.getJavaModel());
attachedSourceDelta.sourceAttached(fragment);
manager.getDeltaProcessor().fire(attachedSourceDelta, ElementChangedEvent.POST_CHANGE);
}
} catch (CoreException e) {
// ignore
}
}