项目: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;
}
@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);
}
}
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
IResource resource = proxy.requestResource();
if (tsconfigFile.equals(resource)) {
return true;
}
int type = proxy.getType();
if (type == IResource.FILE && !(TypeScriptResourceUtil.isTsOrTsxFile(resource)
|| TypeScriptResourceUtil.isJsOrJsMapFile(resource))) {
return false;
}
if (tsconfig.isInScope(resource)) {
if (type == IResource.PROJECT || type == IResource.FOLDER) {
return true;
} else {
members.add(resource);
}
return true;
}
return false;
}
项目:testability-explorer
文件:JavaPackageVisitorTest.java
public void testVisitFolderParentFolderPathDoesNotEqualsPath() throws Exception {
List<String> javaPackages = new ArrayList<String>();
String parentFolderPath = "Something";
String additionalPath = "Else";
JavaPackageVisitor visitor = new JavaPackageVisitor(javaPackages,parentFolderPath);
IResourceProxy proxy = createMock(IResourceProxy.class);
expect(proxy.getType()).andReturn(IResource.FOLDER);
expect(proxy.requestFullPath()).andReturn(
new Path(parentFolderPath + System.getProperty("file.separator") + additionalPath));
replay(proxy);
assertTrue(visitor.visit(proxy));
assertEquals(1,javaPackages.size());
assertEquals(additionalPath,javaPackages.get(0));
verify(proxy);
}
项目:KaiZen-OpenAPI-Editor
文件:SwaggerFileFinder.java
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
if (proxy.getType() == IResource.FILE
&& (proxy.getName().endsWith("yaml") || proxy.getName().endsWith("yml"))) {
if (!proxy.isDerived()) {
IFile file = (IFile) proxy.requestResource();
if (!file.equals(currentFile)) {
String currFileType = file.getContentDescription().getContentType().getId();
if (fileContentType == null || fileContentType.equals(currFileType)) {
files.add(file);
}
}
}
} else if (proxy.getType() == IResource.FOLDER
&& (proxy.isDerived() || proxy.getName().equalsIgnoreCase("gentargets"))) {
return false;
}
return true;
}
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);
}
}
}
/**
* @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());
}
public boolean visit(IResourceProxy proxy) {
if (fMonitor.isCanceled()) {
throw new OperationCanceledException();
}
if (proxy.getType() == IResource.FILE) {
String name= proxy.getName();
if (isValidCUName(name)) {
visitcompilationunit((IFile) proxy.requestResource());
} else if (hasExtension(name,".class")) { //$NON-NLS-1$
fClassFiles.add(proxy.requestResource());
} else if (hasExtension(name,".jar")) { //$NON-NLS-1$
fJARFiles.add(proxy.requestFullPath());
}
return false;
}
return true;
}
@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)))
{
configFiles.put(file,contentType);
}
}
}
return true;
}
项目:eclipse-wtp-webresources
文件:WebResourcesProxyVisitor.java
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
int type = proxy.getType();
switch (type) {
case IResource.FOLDER:
case IResource.PROJECT:
IResource resource = proxy.requestResource();
return resource.equals(current);
case IResource.FILE:
if (ResourceHelper.isMatchingWebResourceType(proxy.getName(),context.getResourceType().getType())) {
// current file matches the given web resource type
// collect it.
IResource file = proxy.requestResource();
if (collector.add(file,WebResourceKind.ECLIPSE_RESOURCE,context,resolver)) {
stop = true;
}
}
default:
break;
}
return !stop;
}
项目:idecore
文件:ApexResourcesVisitor.java
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
switch (proxy.getType()) {
case IResource.FILE:
if (proxy.getName().endsWith(classExtension)
|| proxy.getName().endsWith(triggerExtension)) {
files.add((IFile) proxy.requestResource());
}
return false;
case IResource.FOLDER:
// Only traverse resources that are not inside the Referenced Packages folder
return !proxy.getName().equals(Constants.REFERENCED_PACKAGE_FOLDER_NAME);
case IResource.PROJECT:
return true;
default:
return false;
}
}
public boolean visit(IResourceProxy proxy) {
if (fMonitor.isCanceled()) {
throw new OperationCanceledException();
}
if (proxy.getType() == IResource.FILE) {
String name= proxy.getName();
if (isValidCUName(name)) {
visitcompilationunit((IFile) proxy.requestResource());
} else if (hasExtension(name,".jar")) { //$NON-NLS-1$
fJARFiles.add(proxy.requestFullPath());
}
return false;
}
return true;
}
项目:m2e-plugins
文件:CheckLastModifiedVisitor.java
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
if (terminated) {
return false;
}
IResource resource = proxy.requestResource();
long value = (resource.getLocalTimeStamp() / 1000) * 1000;
if (value > lastModified) {
lastModified = value;
if (lastModified > threashold) {
terminated = true;
return false;
}
}
return true;
}
项目:ec4e
文件:AbstractSectionPatternVisitor.java
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
IPath path = proxy.requestFullPath();
if (proxy.getType() == IResource.FILE && section.match(Ec4jPaths.of(path.toString()))) {
collect(proxy);
}
return true;
}
项目:mesfavoris
文件:FuzzyResourceFinder.java
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
if (proxy.getName().equals(expectedname) && proxy.getType() == type) {
IResource resource = proxy.requestResource();
int distance = resourcePathdistanceComputer.distance(expectedpath,resource.getFullPath());
if (distance < resourceCandidatedistance) {
resourceCandidate = resource;
resourceCandidatedistance = distance;
}
}
return true;
}
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
if (FileUtils.isTsConfigFile(proxy.getName())) {
collect(proxy.requestResource());
}
return true;
}
项目:ForgedUI-Eclipse
文件:TitaniumProjectsManager.java
public boolean visit(IResourceProxy resourceProxy) {
switch (resourceProxy.getType()) {
case IResource.ROOT :
return true; // all projects are in the "root"
case IResource.PROJECT :
this.processproject(resourceProxy);
return false; // no nested projects
case IResource.FOLDER :
return false; // ignore
case IResource.FILE :
return false; // ignore
default :
return false;
}
}
项目: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);
}
public boolean contains(IResourceProxy proxy) {
if (!fVisitDerived && proxy.isDerived()) {
return false; // all resources in a derived folder are considered to be derived,see bug
// 103576
}
if (proxy.getType() == IResource.FILE) {
return matchesFileName(proxy.getName());
}
return true;
}
项目:testability-explorer
文件:JavaPackageVisitorTest.java
public void testVisitSimple() throws Exception {
JavaPackageVisitor visitor = new JavaPackageVisitor(null,null);
IResourceProxy proxy = createMock(IResourceProxy.class);
expect(proxy.getType()).andReturn(IResource.FILE);
replay(proxy);
assertFalse(visitor.visit(proxy));
verify(proxy);
}
项目:testability-explorer
文件:JavaPackageVisitorTest.java
public void testVisitFolderParentFolderPathEqualsPath() throws Exception {
List<String> javaPackages = null;
String parentFolderPath = "Something";
JavaPackageVisitor visitor = new JavaPackageVisitor(javaPackages,parentFolderPath);
IResourceProxy proxy = createMock(IResourceProxy.class);
expect(proxy.getType()).andReturn(IResource.FOLDER);
expect(proxy.requestFullPath()).andReturn(new Path(parentFolderPath));
replay(proxy);
assertTrue(visitor.visit(proxy));
verify(proxy);
}
项目:testability-explorer
文件:JavaPackageVisitor.java
public boolean visit(IResourceProxy proxy) {
if (proxy.getType() == IResource.FOLDER) {
String pathString = proxy.requestFullPath().toOsstring();
if (!parentFolderPath.equals(pathString)) {
pathString = pathString.substring(parentFolderPath.length() + 1,pathString.length());
pathString = pathString.replace("\\","/");
javaPackages.add(pathString);
}
return true;
} else {
return false;
}
}
public boolean visit(IResourceProxy proxy) throws CoreException {
IResource r = proxy.requestResource();
if (proxy != null && proxy.isLinked()) {
if ((r instanceof IFolder || r.getFileExtension() != null && r.getFileExtension().equalsIgnoreCase(FileExtension.JRXML)) && r.getLocation() != null && !r.getLocation().toFile().exists())
r.delete(true,monitor);
}
if (monitor.isCanceled())
return false;
return true;
}
private boolean shouldValidate(IResourceProxy proxy) {
if (proxy.getType() == IResource.FILE) {
String name = proxy.getName();
if (name.toLowerCase(Locale.US).endsWith(".json")) { //$NON-NLS-1$
return true;
}
}
return shouldValidate(proxy.requestResource(),false);
}
项目:eclipse-filecompletion
文件:ResourceFinder.java
public boolean visit(IResourceProxy proxy) throws CoreException {
if (foundedResource != null) {
return false;
}
IResource reSEOurce = proxy.requestResource();
File file;// = resource.getFullPath().toFile();
IPath location = reSEOurce.getLocation();
if (location == null) {
// LOG.info("bad loacation ");
return true;
}
file = location.toFile();
// .toFile();
if (file == null) {
LOG.info("file is null " + reSEOurce);
} else {
if (file.getName().equals(filetoFind.getName())) {
if (file.isFile()) {
String path;
try {
path = getFilePathABS(file);
LOG.info(absPath);
if (absPath.equals(path)) {
LOG.info("found");
this.foundedResource = reSEOurce;
}
LOG.info(path);
} catch (IOException e) {
LOG.log(Level.SEVERE,file + "",e);
}
} else {
LOG.info("not a file " + file);
}
}
}
if (reSEOurce.getType() == IResource.FILE) {
return false;
}
return true;
}
项目:mybatipse
文件:MybatipseIncrementalBuilder.java
@Override
public boolean visit(IResourceProxy proxy) throws CoreException
{
if (proxy.isDerived())
return false;
count++;
return true;
}
项目:ec4e
文件:CountSectionPatternVisitor.java
@Override
protected void collect(IResourceProxy proxy) {
nbFiles++;
}
项目:ForgedUI-Eclipse
文件:TitaniumProjectsManager.java
private void processproject(IResourceProxy resourceProxy) {
if (resourceProxy.isAccessible()) { // the project exists and is open
IProject project = (IProject) resourceProxy.requestResource();
TitaniumProjectsManager.this.addTitaniumProject(project);
}
}
项目:VariantSync
文件:ProjectRoot.java
@Override
public IResourceProxy createProxy() {
// not required
return null;
}
项目:che
文件:Resource.java
@Override
public IResourceProxy createProxy() {
throw new UnsupportedOperationException();
}
public boolean visit(IResourceProxy proxy) throws CoreException {
if (proxy.getType() == IResource.FILE)
checkFile((IFile) proxy.requestResource());
return true;
}
public boolean visit(IResourceProxy proxy) {
if (progressMonitor.isCanceled())
return false;
IResource resource = proxy.requestResource();
proxyContentProvider.add(resource,resourceFilter);
if (resource.getType() == IResource.FOLDER && resource.isDerived()
&& !resourceFilter.isShowDerived()) {
return false;
}
if (resource.getType() == IResource.FILE) {
return false;
}
return true;
}
public boolean visit(IResourceProxy proxy) {
if (progressMonitor.isCanceled())
return false;
IResource resource = proxy.requestResource();
proxyContentProvider.add(resource,resourceFilter);
if (resource.getType() == IResource.FOLDER && resource.isDerived()
&& !resourceFilter.isShowDerived()) {
return false;
}
if (resource.getType() == IResource.FILE) {
return false;
}
return true;
}
项目:PerformanceHat
文件:AbstractBaseResourceDecorator.java
/**
* {@inheritDoc}
*/
@Override
public IResourceProxy createProxy() {
return resource().createProxy();
}
项目:XPagesExtensionLibrary
文件:TestFile.java
public IResourceProxy createProxy() {
throw new RuntimeException("not implemented"); //$NON-NLS-1$
// return null;
}
项目: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);
}
}
项目: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,"Build Failed... Build artifact does not exist"));
}
}
finally{
sm.done();
}
}