use of org.eclipse.core.resources.IFolder in project che by eclipse.
the class DeltaProcessor method updateRootIndex.
/*
* Updates the index of the given root (assuming it's an addition or a removal).
* This is done recusively, pkg being the current package.
*/
private void updateRootIndex(PackageFragmentRoot root, String[] pkgName, IResourceDelta delta) {
Openable pkg = root.getPackageFragment(pkgName);
updateIndex(pkg, delta);
IResourceDelta[] children = (IResourceDelta[]) delta.getAffectedChildren();
for (int i = 0, length = children.length; i < length; i++) {
IResourceDelta child = children[i];
IResource resource = child.getResource();
if (resource instanceof IFolder) {
String[] subpkgName = Util.arrayConcat(pkgName, resource.getName());
updateRootIndex(root, subpkgName, child);
}
}
}
use of org.eclipse.core.resources.IFolder in project che by eclipse.
the class JavaElementResourceMapping method getPackageFragmentTraversals.
private static ResourceTraversal[] getPackageFragmentTraversals(IPackageFragment pack) throws CoreException {
ArrayList<ResourceTraversal> res = new ArrayList<ResourceTraversal>();
IContainer container = (IContainer) pack.getResource();
if (container != null) {
res.add(new ResourceTraversal(new IResource[] { container }, IResource.DEPTH_ONE, 0));
if (pack.exists()) {
// folder may not exist any more, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=269167
Object[] nonJavaResources = pack.getNonJavaResources();
for (int i = 0; i < nonJavaResources.length; i++) {
Object resource = nonJavaResources[i];
if (resource instanceof IFolder) {
res.add(new ResourceTraversal(new IResource[] { (IResource) resource }, IResource.DEPTH_INFINITE, 0));
}
}
}
}
return res.toArray(new ResourceTraversal[res.size()]);
}
use of org.eclipse.core.resources.IFolder in project che by eclipse.
the class JavaElementResourceMapping method getRemotePackageFragmentTraversals.
private static ResourceTraversal[] getRemotePackageFragmentTraversals(IPackageFragment pack, RemoteResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
ArrayList<ResourceTraversal> res = new ArrayList<ResourceTraversal>();
IContainer container = (IContainer) pack.getResource();
if (container != null) {
res.add(new ResourceTraversal(new IResource[] { container }, IResource.DEPTH_ONE, 0));
IResource[] remoteMembers = context.fetchRemoteMembers(container, monitor);
if (remoteMembers == null) {
remoteMembers = context.fetchMembers(container, monitor);
}
if (remoteMembers != null) {
for (int i = 0; i < remoteMembers.length; i++) {
IResource member = remoteMembers[i];
if (member instanceof IFolder && JavaConventionsUtil.validatePackageName(member.getName(), pack).getSeverity() == IStatus.ERROR) {
res.add(new ResourceTraversal(new IResource[] { member }, IResource.DEPTH_INFINITE, 0));
}
}
}
}
return res.toArray(new ResourceTraversal[res.size()]);
}
use of org.eclipse.core.resources.IFolder in project che by eclipse.
the class RenameNonPrivateFieldTest method createPropertiesFromTestFile.
private IFile createPropertiesFromTestFile(String propertyName) throws IOException, CoreException {
IFolder pack = (IFolder) getPackageP().getResource();
IFile file = pack.getFile(propertyName + ".properties");
String fileName = getInputTestFileName(propertyName);
fileName = fileName.substring(0, fileName.length() - ".java".length()) + ".properties";
InputStream inputStream = getFileInputStream(fileName);
file.create(inputStream, true, null);
return file;
}
use of org.eclipse.core.resources.IFolder in project che by eclipse.
the class RenamePackageTest method testPackageRenameWithResource1.
@Test
public void testPackageRenameWithResource1() throws Exception {
IPackageFragment fragment = getRoot().createPackageFragment("org.test", true, null);
StringBuffer buf = new StringBuffer();
buf.append("package org.test;\n");
buf.append("public class MyClass {\n");
buf.append(" org.test.MyClass me;\n");
buf.append("}\n");
fragment.createCompilationUnit("MyClass.java", buf.toString(), true, null);
IFile file = ((IFolder) getRoot().getResource()).getFile("x.properties");
byte[] content = "This is about 'org.test' and more".getBytes();
file.create(new ByteArrayInputStream(content), true, null);
file.refreshLocal(IResource.DEPTH_ONE, null);
RenameJavaElementDescriptor descriptor = RefactoringSignatureDescriptorFactory.createRenameJavaElementDescriptor(IJavaRefactorings.RENAME_PACKAGE);
descriptor.setJavaElement(fragment);
descriptor.setNewName("org.test2");
descriptor.setUpdateReferences(true);
descriptor.setUpdateQualifiedNames(true);
descriptor.setFileNamePatterns("*.properties");
Refactoring refactoring = createRefactoring(descriptor);
RefactoringStatus status = performRefactoring(refactoring);
if (status != null)
assertTrue(status.toString(), status.isOK());
RefactoringProcessor processor = ((RenameRefactoring) refactoring).getProcessor();
IResourceMapper rm = (IResourceMapper) processor.getAdapter(IResourceMapper.class);
IJavaElementMapper jm = (IJavaElementMapper) processor.getAdapter(IJavaElementMapper.class);
checkMappingUnchanged(jm, rm, new Object[] { getRoot().getJavaProject(), getRoot(), file });
IFile newFile = ((IContainer) getRoot().getResource()).getFile(new Path("x.properties"));
assertEquals("This is about 'org.test2' and more", getContents(newFile));
checkMappingChanged(jm, rm, new Object[][] { { fragment, getRoot().getPackageFragment("org.test2") } });
}
Aggregations