本文整理汇总了Java中org.eclipse.core.resources.IResource.accept方法的典型用法代码示例。如果您正苦于以下问题:Java IResource.accept方法的具体用法?Java IResource.accept怎么用?Java IResource.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.core.resources.IResource
的用法示例。
在下文中一共展示了IResource.accept方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectAllWorkspaceFiles
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public static List<ResourceItem> collectAllWorkspaceFiles(IWorkspaceRoot workspace) {
List<ResourceItem> files = new ArrayList<>();
IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) throws CoreException {
if (proxy.getType() != IResource.FILE) return true;
if (proxy.isDerived()) return false;
if (proxy.isPhantom()) return false;
if (proxy.isHidden()) return false;
IFile file = (IFile) proxy.requestResource();
files.add(makeResourceItem(file));
return false;
}
};
try {
IResource[] resources = workspace.members();
for(IResource resource : resources) {
if (!resource.getProject().isOpen()) continue;
resource.accept(visitor, 0);
}
} catch (CoreException e) {
throw new RuntimeException(e);
}
return files;
}
示例2: select
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
protected boolean select(IResource resource) {
boolean result = super.select(resource);
if(resource instanceof IProject){
boolean hasFileWithExtension = false;
try {
resource.accept(projectVisitor);
hasFileWithExtension = projectVisitor.getFile() != null;
} catch (CoreException e) {
Activator.error(e.getMessage(), e);
}
result = result && hasFileWithExtension;
}
return result;
}
示例3: accept
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {
if (depth == DEPTH_ZERO) {
visitor.visit(this);
} else {
if (visitor.visit(this)) {
for (IResource member : members()) {
member.accept(visitor, DEPTH_ONE == depth ? DEPTH_ZERO : DEPTH_INFINITE, memberFlags);
}
}
}
}
示例4: guessPackageRootFragment
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
public static IPath guessPackageRootFragment(IProject project, boolean main)
throws CoreException, FileNotFoundException {
IPath folder = project.getFullPath()
.append(GraphWalkerContextManager.getTargetFolderForTestInterface(project.getName(), main));
IResource interfaceFolder = ResourceManager.toResource(folder);
List<IPath> paths = new ArrayList<IPath>();
if (interfaceFolder != null) {
interfaceFolder.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
IJavaElement element = JavaCore.create(resource);
if (element != null && element instanceof ICompilationUnit) {
try {
ICompilationUnit cu = (ICompilationUnit) element;
CompilationUnit ast = parse(cu);
ast.accept(new ASTVisitor() {
public boolean visit(PackageDeclaration node) {
PackageDeclaration decl = (PackageDeclaration) node;
String pkgname = decl.getName().getFullyQualifiedName();
int sizePath = pkgname.split("\\.").length;
paths.add(resource.getParent().getFullPath().removeLastSegments(sizePath));
return false;
}
});
} catch (Exception e) {
ResourceManager.logException(e);
}
}
return true;
}
});
}
if (paths.size() == 0)
return null;
return paths.get(0);
}
示例5: getExistingGeneratedTestInterfaces
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* @param project
* @return
* @throws CoreException
* @throws FileNotFoundException
*/
public static ICompilationUnit[] getExistingGeneratedTestInterfaces(IProject project, boolean main)
throws CoreException, FileNotFoundException {
IPath folder = project.getFullPath()
.append(GraphWalkerContextManager.getTargetFolderForTestInterface(project.getName(), main));
List<ICompilationUnit> units = new ArrayList<ICompilationUnit>();
IResource interfaceFolder = ResourceManager.toResource(folder);
if (interfaceFolder != null) {
interfaceFolder.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
IJavaElement element = JavaCore.create(resource);
if (element != null && element instanceof ICompilationUnit) {
try {
ICompilationUnit cu = (ICompilationUnit) element;
IType interf = cu.findPrimaryType();
if (interf != null && interf.isInterface()) {
units.add(cu);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return true;
}
});
}
ICompilationUnit[] ret = new ICompilationUnit[units.size()];
units.toArray(ret);
return ret;
}
示例6: select
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
@Override
protected boolean select(IResource resource) {
boolean result = super.select(resource);
if(resource instanceof IFile) {
FileFinderVisitor finder = instanciateFinder();
try {
resource.accept(finder);
result = finder.getFile() != null;
} catch (CoreException e) {
Activator.error(e.getMessage(), e);
}
}
return result;
}
示例7: synchronizeBuildPolicies
import org.eclipse.core.resources.IResource; //导入方法依赖的package包/类
/**
* @param selectedResource
* @return
* @throws CoreException
* @throws InterruptedException
*/
public static void synchronizeBuildPolicies(final IResource selectedResource, IWorkbenchWindow aww)
throws CoreException, InterruptedException {
List<ICompilationUnit> executionContexts = new ArrayList<ICompilationUnit>();
Job job = new WorkspaceJob("GW4E Synchronization Job") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
SubMonitor subMonitor = SubMonitor.convert(monitor, 120);
selectedResource.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
if (resource instanceof IFile) {
IFile file = (IFile) resource;
if ("java".equals(file.getFileExtension())) {
ICompilationUnit cu = JavaCore.createCompilationUnitFrom(file);
if (cu != null) {
if (JDTManager.isGraphWalkerExecutionContextClass(cu)) {
executionContexts.add(cu);
}
}
}
}
return true;
}
});
subMonitor.split(20);
int max = executionContexts.size();
int index = 1;
subMonitor.setWorkRemaining(max);
for (ICompilationUnit executionContext : executionContexts) {
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
subMonitor.subTask("Processing file #" + index++);
SubMonitor child = subMonitor.split(1);
ResourceManager.updateBuildPolicyFileForCompilatioUnit(executionContext);
}
} catch (Exception e) {
ResourceManager.logException(e);
}
return Status.OK_STATUS;
}
};
job.setRule(selectedResource.getProject());
job.setUser(true);
job.schedule();
}