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