Java 类org.eclipse.core.resources.IResourceProxyVisitor 实例源码

项目:eclipse-plugin-commander    文件:EclipseWorkbench.java   
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;
}
项目:eclipse-wtp-json    文件:JSONSyntaxValidator.java   
private void validateProject(IValidationContext helper,
        final IReporter reporter) {
    // if uris[] length 0 -> validate() gets called for each project
    if (helper instanceof IWorkbenchContext) {
        IProject project = ((IWorkbenchContext) helper).getProject();
        IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
            public boolean visit(IResourceProxy proxy) throws CoreException {
                if (shouldValidate(proxy)) {
                    validateFile((IFile) proxy.requestResource(), reporter);
                }
                return true;
            }
        };
        try {
            // collect all jsp files for the project
            project.accept(visitor, IResource.DEPTH_INFINITE);
        } catch (CoreException e) {
            Logger.logException(e);
        }
    }
}
项目:APICloud-Studio    文件:ProjectListSelectionDialog.java   
/**
 * @param parent
 */
public ProjectListSelectionDialog(Shell parent) {
    super(parent, WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    setTitle(Messages.ProjectSelectionDialog_Title);
    setMessage(Messages.ProjectSelectionDialog_Message);
    final List<Object> list = new ArrayList<Object>();
    try {
        ResourcesPlugin.getWorkspace().getRoot().accept(new IResourceProxyVisitor() {
            public boolean visit(IResourceProxy proxy) throws CoreException {
                if (proxy.getType() == IResource.ROOT) {
                    return true;
                }
                if (proxy.isAccessible()) {
                    list.add(proxy.requestResource());
                }
                return false;
            }
        }, 0);
    } catch (CoreException e) {
        IdeLog.logError(UIPlugin.getDefault(), e);
    }
    setElements(list.toArray());
}
项目:che    文件:Resource.java   
@Override
public void accept(final IResourceVisitor visitor, int depth, int memberFlags)
    throws CoreException {
  // use the fast visitor if visiting to infinite depth
  if (depth == IResource.DEPTH_INFINITE) {
    accept(
        new IResourceProxyVisitor() {
          public boolean visit(IResourceProxy proxy) throws CoreException {
            return visitor.visit(proxy.requestResource());
          }
        },
        memberFlags);
    return;
  }
  // it is invalid to call accept on a phantom when INCLUDE_PHANTOMS is not specified
  final boolean includePhantoms = (memberFlags & IContainer.INCLUDE_PHANTOMS) != 0;
  ResourceInfo info = getResourceInfo(includePhantoms, false);
  int flags = getFlags(info);
  if ((memberFlags & IContainer.DO_NOT_CHECK_EXISTENCE) == 0) checkAccessible(flags);

  // check that this resource matches the member flags
  if (!isMember(flags, memberFlags)) return;
  // visit this resource
  if (!visitor.visit(this) || depth == DEPTH_ZERO) return;
  // get the info again because it might have been changed by the visitor
  info = getResourceInfo(includePhantoms, false);
  if (info == null) return;
  // thread safety: (cache the type to avoid changes -- we might not be inside an operation)
  int type = info.getType();
  if (type == FILE) return;
  // if we had a gender change we need to fix up the resource before asking for its members
  IContainer resource =
      getType() != type
          ? (IContainer) workspace.newResource(getFullPath(), type)
          : (IContainer) this;
  IResource[] members = resource.members(memberFlags);
  for (int i = 0; i < members.length; i++)
    members[i].accept(visitor, DEPTH_ZERO, memberFlags | IContainer.DO_NOT_CHECK_EXISTENCE);
}
项目:OpenSPIFe    文件:EnsembleOpenResourceDialog.java   
@Override
protected void fillContentProvider(AbstractContentProvider contentProvider,
        ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
        throws CoreException {
    if (itemsFilter instanceof ResourceFilter) {
        IResourceProxyVisitor resourceProxyVisitor = getNewResourceProxyVisitor(contentProvider, itemsFilter,
                progressMonitor);
        container.accept(resourceProxyVisitor,
                IResource.NONE);
    }
    if (progressMonitor != null)
        progressMonitor.done();

}
项目:VariantSync    文件:ProjectRoot.java   
@Override
public void accept(IResourceProxyVisitor visitor, int memberFlags)
        throws CoreException {
    // not required
}
项目:VariantSync    文件:ProjectRoot.java   
@Override
public void accept(IResourceProxyVisitor arg0, int arg1, int arg2)
        throws CoreException {
    // not required
}
项目:che    文件:Resource.java   
@Override
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
  accept(visitor, IResource.DEPTH_INFINITE, memberFlags);
}
项目:PerformanceHat    文件:AbstractBaseResourceDecorator.java   
/**
 * {@inheritDoc}
 */
@Override
public void accept(final IResourceProxyVisitor visitor, final int memberFlags) throws CoreException {
  resource().accept(visitor, memberFlags);
}
项目:PerformanceHat    文件:AbstractBaseResourceDecorator.java   
/**
 * {@inheritDoc}
 */
@Override
public void accept(final IResourceProxyVisitor visitor, final int depth, final int memberFlags) throws CoreException {
  resource().accept(visitor, depth, memberFlags);
}
项目:OpenSPIFe    文件:EnsembleOpenResourceDialog.java   
protected abstract IResourceProxyVisitor getNewResourceProxyVisitor(
AbstractContentProvider contentProvider, ItemsFilter itemsFilter,
IProgressMonitor progressMonitor) throws CoreException;
项目:XPagesExtensionLibrary    文件:TestFile.java   
public void accept(IResourceProxyVisitor arg0, int arg1) throws CoreException {
    throw new RuntimeException("not implemented"); //$NON-NLS-1$
}
项目:mybatipse    文件:MapperNamespaceCache.java   
private void collectMappers(IJavaProject project, final Map<String, IFile> map,
    final IReporter reporter)
{
    try
    {
        for (IPackageFragmentRoot root : project.getAllPackageFragmentRoots())
        {
            if (root.getKind() != IPackageFragmentRoot.K_SOURCE)
            {
                continue;
            }

            root.getResource().accept(new IResourceProxyVisitor()
            {
                @Override
                public boolean visit(IResourceProxy proxy) throws CoreException
                {
                    if (!proxy.isDerived() && proxy.getType() == IResource.FILE
                        && proxy.getName().endsWith(".xml"))
                    {
                        IFile file = (IFile)proxy.requestResource();
                        IContentDescription contentDesc = file.getContentDescription();
                        if (contentDesc != null)
                        {
                            IContentType contentType = contentDesc.getContentType();
                            if (contentType != null && contentType.isKindOf(mapperContentType))
                            {
                                String namespace = extractNamespace(file);
                                if (namespace != null)
                                {
                                    map.put(namespace, file);
                                }
                                return false;
                            }
                        }
                    }
                    return true;
                }
            }, IContainer.NONE);
        }
    }
    catch (CoreException e)
    {
        Activator.log(Status.ERROR, "Searching MyBatis Mapper xml failed.", e);
    }
}
项目:mybatipse    文件:MybatipseIncrementalBuilder.java   
private void validateAllMappers(final IProgressMonitor monitor)
{
    final int totalWork = countResources();
    monitor.beginTask("Mybatipse validation", totalWork);
    currentWork = 1;

    try
    {
        getProject().accept(new IResourceProxyVisitor()
        {
            private MessageFormat pattern = new MessageFormat("Validating {0}... ({1}/{2})");

            @Override
            public boolean visit(IResourceProxy proxy) throws CoreException
            {
                if (monitor.isCanceled())
                {
                    forgetLastBuiltState();
                    throw new OperationCanceledException();
                }

                monitor.subTask(pattern.format(new Object[]{
                    proxy.getName(), currentWork, totalWork
                }));

                if (proxy.isDerived())
                    return false;

                if (proxy.getType() == IResource.FILE && proxy.getName().endsWith(".xml"))
                {
                    IFile file = (IFile)proxy.requestResource();
                    IContentDescription contentDesc = file.getContentDescription();
                    if (contentDesc != null)
                    {
                        IContentType contentType = contentDesc.getContentType();
                        if (contentType != null && (contentType.isKindOf(configContentType)
                            || contentType.isKindOf(mapperContentType)))
                        {
                            ValidationFramework.getDefault().validate(file, monitor);
                        }
                    }
                }

                monitor.worked(1);
                currentWork++;
                return true;
            }
        }, IContainer.NONE);
    }
    catch (CoreException e)
    {
        Activator.log(Status.ERROR, e.getMessage(), e);
    }
    finally
    {
        monitor.done();
    }
}
项目:mybatipse    文件:MybatipseIncrementalBuilder.java   
@Override
protected void clean(IProgressMonitor monitor) throws CoreException
{
    try
    {
        IProject project = getProject();
        project.accept(new IResourceProxyVisitor()
        {
            @Override
            public boolean visit(IResourceProxy proxy) throws CoreException
            {
                if (proxy.isDerived())
                    return false;

                if (proxy.getType() == IResource.FILE && proxy.getName().endsWith(".xml"))
                {
                    IFile file = (IFile)proxy.requestResource();
                    IContentDescription contentDesc = file.getContentDescription();
                    if (contentDesc != null)
                    {
                        IContentType contentType = contentDesc.getContentType();
                        if (contentType != null && (contentType.isKindOf(configContentType)
                            || contentType.isKindOf(springConfigContentType)))
                        {
                            file.deleteMarkers(XmlValidator.MARKER_ID, false, IResource.DEPTH_ZERO);
                        }
                    }
                }
                return true;
            }
        }, IContainer.NONE);

        TypeAliasCache.getInstance().remove(project);
        BeanPropertyCache.clearBeanPropertyCache(project);
        MapperNamespaceCache.getInstance().remove(project);
        ConfigRegistry.getInstance().remove(project);
    }
    catch (CoreException e)
    {
        Activator.log(Status.ERROR, e.getMessage(), e);
    }
}
项目:thym    文件:BuildDelegate.java   
@Override
public void buildNow(IProgressMonitor monitor) throws CoreException {
    if(monitor.isCanceled())
        return;

    SubMonitor sm = SubMonitor.convert(monitor, "Build project for Android", 100);

    try {
        HybridProject hybridProject = HybridProject.getHybridProject(this.getProject());
        if (hybridProject == null) {
            throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID,
                    "Not a hybrid mobile project, can not generate files"));
        }
        String buildType = "--debug";
        if(isRelease()){
            buildType = "--release";
        }
        hybridProject.build(sm.split(90), "android",buildType);

        IFolder androidProject = hybridProject.getProject().getFolder("platforms/android");
        androidProject.accept(new IResourceProxyVisitor() {

            @Override
            public boolean visit(IResourceProxy proxy) throws CoreException {
                switch (proxy.getType()) {
                case IResource.FOLDER:
                    for (String folder : outputFolders) {
                            if(folder.equals(proxy.getName())){
                            return true;
                        }
                    }
                    break;
                case IResource.FILE:
                    if(isRelease() && proxy.getName().endsWith("-release-unsigned.apk")){
                        setBuildArtifact(proxy.requestResource().getLocation().toFile());
                        return false;
                    }
                    if(proxy.getName().endsWith("-debug.apk")){
                        setBuildArtifact(proxy.requestResource().getLocation().toFile());
                        return false;
                    }
                default:
                    break;
                }
                return false;
            }
        }, IContainer.INCLUDE_HIDDEN | IContainer.INCLUDE_PHANTOMS | IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS );

        if(getBuildArtifact() == null || !getBuildArtifact().exists()){
            throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID, "Build failed... Build artifact does not exist"));
        }
    }
    finally{
        sm.done();
    }
}
项目:Pydev    文件:AbstractIResourceStub.java   
@Override
public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {
    throw new RuntimeException("Not implemented");
}
项目:Pydev    文件:AbstractIResourceStub.java   
@Override
public void accept(IResourceProxyVisitor visitor, int depth, int memberFlags) throws CoreException {
}