本文整理汇总了Java中org.eclipse.core.resources.IContainer.accept方法的典型用法代码示例。如果您正苦于以下问题:Java IContainer.accept方法的具体用法?Java IContainer.accept怎么用?Java IContainer.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IContainer
的用法示例。
在下文中一共展示了IContainer.accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
@Override
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
startTime = System.currentTimeMillis();
AbstractTextSearchResult textResult = (AbstractTextSearchResult) getSearchResult();
textResult.removeAll();
try {
IContainer dir = configFile.getParent();
dir.accept(new AbstractSectionPatternVisitor(section) {
@Override
protected void collect(IResourceProxy proxy) {
Match match = new FileMatch((IFile) proxy.requestResource());
result.addMatch(match);
}
}, IResource.NONE);
return Status.OK_STATUS;
} catch (Exception ex) {
return new Status(IStatus.ERROR, EditorConfigPlugin.PLUGIN_ID, ex.getMessage(), ex);
}
}
示例2: getFolderIterator
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
@Override
public UnmodifiableIterator<URI> getFolderIterator(URI folderLocation) {
final IContainer container;
if (DIRECT_RESOURCE_IN_PROJECT_SEGMENTCOUNT == folderLocation.segmentCount()) {
container = workspace.getProject(folderLocation.lastSegment());
} else {
container = workspace.getFolder(new Path(folderLocation.toPlatformString(true)));
}
if (container != null && container.exists()) {
final List<URI> result = Lists.newLinkedList();
try {
container.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
if (resource.getType() == IResource.FILE) {
result.add(URI.createPlatformResourceURI(resource.getFullPath().toString(), true));
}
return true;
}
});
return Iterators.unmodifiableIterator(result.iterator());
} catch (CoreException e) {
return Iterators.unmodifiableIterator(result.iterator());
}
}
return Iterators.emptyIterator();
}
示例3: getFolderIterator
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
@Override
public Iterator<URI> getFolderIterator(URI folderLocation) {
ensureInitialized();
final URI findProjectWith = findProjectWith(folderLocation);
if (null != findProjectWith) {
final String projectName = findProjectWith.lastSegment();
final ExternalProject project = getProjectMapping().get(projectName);
if (null != project) {
String projectPath = new File(project.getLocationURI()).getAbsolutePath();
String folderPath = folderLocation.toFileString();
final IContainer container = projectPath.equals(folderPath) ? project
: project.getFolder(folderPath.substring(projectPath.length() + 1));
final Collection<URI> result = Lists.newLinkedList();
try {
container.accept(resource -> {
if (resource instanceof IFile) {
final String path = new File(resource.getLocationURI()).getAbsolutePath();
result.add(URI.createFileURI(path));
}
return true;
});
return unmodifiableIterator(result.iterator());
} catch (CoreException e) {
return unmodifiableIterator(result.iterator());
}
}
}
return emptyIterator();
}
示例4: countFiles
import org.eclipse.core.resources.IContainer; //导入方法依赖的package包/类
public static int countFiles(IContainer container) throws CoreException {
int[] count = new int[1];
container.accept(p -> {
if (p.getType() == IResource.FILE) {
++count[0];
}
return true;
}, 0);
return count[0];
}