Java Code Examples for org.eclipse.core.resources.IFile#isDerived()
The following examples show how to use
org.eclipse.core.resources.IFile#isDerived() .
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: ChangeConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void checkDerived(IFile file) { if (file.isDerived()) { issues.add(RefactoringIssueAcceptor.Severity.WARNING, "Affected file '" + file.getFullPath() + "' is derived"); } }
Example 2
Source File: ValidMarkerUpdateJob.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
/** {@inheritDoc} */ @Override protected IStatus run(final IProgressMonitor monitor) { final IResourceValidator resourceValidator = resourceServiceProvider.getResourceValidator(); // Object the list of resources final List<URI> uris = getResourceDescriptionURIs(); // Let's start (number of task = number of resource * 2 (loading + validating)) monitor.beginTask("", uris.size() * 2); //$NON-NLS-1$ for (final URI uri : uris) { // Last chance to cancel before next validation if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } // Get the file; only local files will be re-validated, derived files are ignored final IFile iFile = getFileFromStorageMapper(uri); if (iFile != null && !iFile.isDerived(IFile.CHECK_ANCESTORS)) { monitor.subTask("loading " + iFile.getName()); //$NON-NLS-1$ // Load the corresponding resource boolean loaded = false; Resource eResource = null; try { eResource = resourceSet.getResource(uri, false); if ((eResource == null) || (eResource != null && !eResource.isLoaded())) { // if the resource does not exist in the resource set, or is not loaded yet // load it. eResource = resourceSet.getResource(uri, true); loaded = true; } monitor.worked(1); // CHECKSTYLE:OFF } catch (final RuntimeException e) { // CHECKSTYLE:ON LOGGER.error(MessageFormat.format("{0} could not be validated.", iFile.getName()), e); //$NON-NLS-1$ } finally { if (eResource != null) { validate(resourceValidator, iFile, eResource, monitor); if (loaded) { // NOPMD // unload any resource that was previously loaded as part of this loop. eResource.unload(); } } } } } monitor.done(); return Status.OK_STATUS; }
Example 3
Source File: DeleteModifications.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
/** * This method collects file and folder deletion for notifying * participants. Participants will get notified of * * * deletion of the package (in any case) * * deletion of files within the package if only the files are deleted without * the package folder ("package cleaning") * * deletion of the package folder if it is not only cleared and if its parent * is not removed as well. * * All deleted resources are added to <code>resourcesCollector</code> * @param pack the package * * @param resourcesCollector a collector for IResources to be deleted * @throws CoreException */ private void handlePackageFragmentDelete(IPackageFragment pack, ArrayList<IResource> resourcesCollector) throws CoreException { final IContainer container= (IContainer)pack.getResource(); if (container == null) return; final IResource[] members= container.members(); /* * Check whether this package is removed completely or only cleared. * The default package can never be removed completely. */ if (!pack.isDefaultPackage() && canRemoveCompletely(pack)) { // This package is removed completely, which means its folder will be // deleted as well. We only notify participants of the folder deletion // if the parent folder of this folder will not be deleted as well: boolean parentIsMarked= false; final IPackageFragment parent= JavaElementUtil.getParentSubpackage(pack); if (parent == null) { // "Parent" is the default package which will never be // deleted physically parentIsMarked= false; } else { // Parent is marked if it is in the list parentIsMarked= fPackagesToDelete.contains(parent); } if (parentIsMarked) { // Parent is marked, but is it really deleted or only cleared? if (canRemoveCompletely(parent)) { // Parent can be removed completely, so we do not add // this folder to the list. } else { // Parent cannot be removed completely, but as this folder // can be removed, we notify the participant resourcesCollector.add(container); getResourceModifications().addDelete(container); } } else { // Parent will not be removed, but we will resourcesCollector.add(container); getResourceModifications().addDelete(container); } } else { // This package is only cleared because it has subpackages (=subfolders) // which are not deleted. As the package is only cleared, its folder // will not be removed and so we must notify the participant of the deleted children. for (int m= 0; m < members.length; m++) { IResource member= members[m]; if (member instanceof IFile) { IFile file= (IFile)member; if ("class".equals(file.getFileExtension()) && file.isDerived()) //$NON-NLS-1$ continue; if (pack.isDefaultPackage() && ! JavaCore.isJavaLikeFileName(file.getName())) continue; resourcesCollector.add(member); getResourceModifications().addDelete(member); } if (!pack.isDefaultPackage() && member instanceof IFolder) { // Normally, folder children of packages are packages // as well, but in case they have been removed from the build // path, notify the participant IPackageFragment frag= (IPackageFragment) JavaCore.create(member); if (frag == null) { resourcesCollector.add(member); getResourceModifications().addDelete(member); } } } } }
Example 4
Source File: ResourceUtil.java From APICloud-Studio with GNU General Public License v3.0 | 2 votes |
/** * If the file is null, doesn't exist, is derived or is team private this returns true. Used to skip files for * build/reconcile. * * @param file * @return */ public static boolean shouldIgnore(IFile file) { return file == null || !file.exists() || file.isTeamPrivateMember(IResource.CHECK_ANCESTORS) || file.isDerived(IResource.CHECK_ANCESTORS); }