Java Code Examples for org.eclipse.jdt.internal.core.util.Util#arrayConcat()

The following examples show how to use org.eclipse.jdt.internal.core.util.Util#arrayConcat() . 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: CopyResourceElementsOperation.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates any destination package fragment(s) which do not exists yet.
 * Return true if a read-only package fragment has been found among package fragments, false otherwise
 */
private boolean createNeededPackageFragments(IContainer sourceFolder, PackageFragmentRoot root, String[] newFragName, boolean moveFolder) throws JavaModelException {
	boolean containsReadOnlyPackageFragment = false;
	IContainer parentFolder = (IContainer) root.resource();
	JavaElementDelta projectDelta = null;
	String[] sideEffectPackageName = null;
	char[][] inclusionPatterns = root.fullInclusionPatternChars();
	char[][] exclusionPatterns = root.fullExclusionPatternChars();
	for (int i = 0; i < newFragName.length; i++) {
		String subFolderName = newFragName[i];
		sideEffectPackageName = Util.arrayConcat(sideEffectPackageName, subFolderName);
		IResource subFolder = parentFolder.findMember(subFolderName);
		if (subFolder == null) {
			// create deepest folder only if not a move (folder will be moved in processPackageFragmentResource)
			if (!(moveFolder && i == newFragName.length-1)) {
				createFolder(parentFolder, subFolderName, this.force);
			}
			parentFolder = parentFolder.getFolder(new Path(subFolderName));
			sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
			if (Util.isReadOnly(sourceFolder)) {
				containsReadOnlyPackageFragment = true;
			}
			IPackageFragment sideEffectPackage = root.getPackageFragment(sideEffectPackageName);
			if (i < newFragName.length - 1 // all but the last one are side effect packages
					&& !Util.isExcluded(parentFolder, inclusionPatterns, exclusionPatterns)) {
				if (projectDelta == null) {
					projectDelta = getDeltaFor(root.getJavaProject());
				}
				projectDelta.added(sideEffectPackage);
			}
			this.createdElements.add(sideEffectPackage);
		} else {
			parentFolder = (IContainer) subFolder;
		}
	}
	return containsReadOnlyPackageFragment;
}
 
Example 2
Source File: DeltaProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updateRootIndex(PackageFragmentRoot root, String[] pkgName, IResourceDelta delta) {
	Openable pkg = root.getPackageFragment(pkgName);
	updateIndex(pkg, delta);
	IResourceDelta[] children = 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);
		}
	}
}