org.eclipse.core.resources.IResourceProxy Java Examples

The following examples show how to use org.eclipse.core.resources.IResourceProxy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SarlClassPathDetector.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public boolean visit(IResourceProxy proxy) {
	if (this.monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	if (proxy.getType() == IResource.FILE) {
		final String name = proxy.getName();
		if (isValidJavaCUName(name)) {
			visitJavaCompilationUnit((IFile) proxy.requestResource());
		} else if (isValidSarlCUName(name)) {
			visitSarlCompilationUnit((IFile) proxy.requestResource());
		} else if (FileSystem.hasExtension(name, ".class")) { //$NON-NLS-1$
			this.classFiles.add(proxy.requestResource());
		} else if (FileSystem.hasExtension(name, ".jar")) { //$NON-NLS-1$
			this.jarFiles.add(proxy.requestFullPath());
		}
		return false;
	}
	return true;
}
 
Example #2
Source File: ClassPathDetector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: TsconfigBuildPath.java    From typescript.java with MIT License 6 votes vote down vote up
@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;
}
 
Example #4
Source File: ProjectListSelectionDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @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());
}
 
Example #5
Source File: TmfExperimentElement.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private List<IResource> getTraceResources() {
    IFolder folder = getResource();
    final List<IResource> list = new ArrayList<>();
    try {
        folder.accept(new IResourceProxyVisitor() {
            @Override
            public boolean visit(IResourceProxy resource) throws CoreException {
                /*
                 * Trace represented by a file, or a link for backward compatibility
                 */
                if (resource.getType() == IResource.FILE || resource.isLinked()) {
                    list.add(resource.requestResource());
                    /* don't visit linked folders, as they might contain files */
                    return false;
                }
                return true;
            }
        }, IResource.NONE);
    } catch (CoreException e) {
    }
    list.sort(Comparator.comparing(resource -> resource.getFullPath().toString()));
    return list;
}
 
Example #6
Source File: SwaggerFileFinder.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 6 votes vote down vote up
@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;
  }
 
Example #7
Source File: JavaPackageVisitorTest.java    From testability-explorer with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #8
Source File: FileNamePatternSearchScope.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
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;
}
 
Example #9
Source File: JavaPackageVisitor.java    From testability-explorer with Apache License 2.0 5 votes vote down vote up
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;
  }
}
 
Example #10
Source File: JavaPackageVisitorTest.java    From testability-explorer with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: JavaPackageVisitorTest.java    From testability-explorer with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #12
Source File: AbstractTsconfigJsonCollector.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
	if (FileUtils.isTsConfigFile(proxy.getName())) {
		collect(proxy.requestResource());
	}
	return true;
}
 
Example #13
Source File: FilesOfScopeCalculator.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(IResourceProxy proxy) {
	boolean inScope= fScope.contains(proxy);

	if (inScope && proxy.getType() == IResource.FILE) {
		fFiles.add(proxy.requestResource());
	}
	return inScope;
}
 
Example #14
Source File: TestFile.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public IResourceProxy createProxy() {
        throw new RuntimeException("not implemented"); //$NON-NLS-1$
//        return null;
    }
 
Example #15
Source File: BuildDelegate.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@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();
	}
}
 
Example #16
Source File: ClientTester.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IResourceProxy createProxy() {
	// TODO Auto-generated method stub
	return null;
}
 
Example #17
Source File: FakeIFile.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IResourceProxy createProxy() {
	// TODO Auto-generated method stub
	return null;
}
 
Example #18
Source File: AbstractIResourceStub.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public IResourceProxy createProxy() {
    throw new RuntimeException("Not implemented");
}
 
Example #19
Source File: TextSearchScope.java    From eclipse.jdt.ls with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns if a given resource is part of the scope. If a container is not part of the scope, also all its members
 * are not part of the scope.
 *
 * @param proxy the resource proxy to test.
 * @return returns <code>true</code> if a resource is part of the scope. if <code>false</code> is returned the resource
 * and all its children are not part of the scope.
 */
public abstract boolean contains(IResourceProxy proxy);