/** * Check whether the input paramenter of type <code> * IPackageFragmentRoot</code> has either it's inclusion or * exclusion filter or both set (that means they are * not empty). * * @param root the fragment root to be inspected * @return <code>true</code> inclusion or exclusion filter set, * <code>false</code> otherwise. */ public static boolean filtersSet(IPackageFragmentRoot root) throws JavaModelException { if (root == null) return false; IClasspathEntry entry= root.getRawClasspathEntry(); IPath[] inclusions= entry.getInclusionPatterns(); IPath[] exclusions= entry.getExclusionPatterns(); if (inclusions != null && inclusions.length > 0) return true; if (exclusions != null && exclusions.length > 0) return true; return false; }
/** * Check whether the input parameter of type <code> * IPackageFragmentRoot</code> has either it's inclusion or * exclusion filter or both set (that means they are * not empty). * * @param root the fragment root to be inspected * @return <code>true</code> inclusion or exclusion filter set, * <code>false</code> otherwise. * @throws JavaModelException */ public static boolean filtersSet(IPackageFragmentRoot root) throws JavaModelException { if (root == null) return false; IClasspathEntry entry= root.getRawClasspathEntry(); IPath[] inclusions= entry.getInclusionPatterns(); IPath[] exclusions= entry.getExclusionPatterns(); if (inclusions != null && inclusions.length > 0) return true; if (exclusions != null && exclusions.length > 0) return true; return false; }
/** * Check whether the input parameter of type <code> * IPackageFragmentRoot</code> has either it's inclusion or * exclusion filter or both set (that means they are * not empty). * * @param root the fragment root to be inspected * @return <code>true</code> inclusion or exclusion filter set, * <code>false</code> otherwise. * @throws JavaModelException */ public static boolean filtersSet(IPackageFragmentRoot root) throws JavaModelException { if (root == null) return false; IClasspathEntry entry= root.getRawClasspathEntry(); IPath[] inclusions= entry.getInclusionPatterns(); IPath[] exclusions= entry.getExclusionPatterns(); if (inclusions != null && inclusions.length > 0) return true; if (exclusions != null && exclusions.length > 0) return true; return false; }
private static IClasspathEntry removeFilters(IClasspathEntry entry, IPath path) { IPath[] inclusionPatterns = entry.getInclusionPatterns(); List<IPath> inclusionList = new ArrayList<>(); if (inclusionPatterns != null) { for (IPath pattern : inclusionPatterns) { if (!path.equals(entry.getPath().append(pattern))) { inclusionList.add(pattern); } } } IPath[] exclusionPatterns = entry.getExclusionPatterns(); List<IPath> exclusionList = new ArrayList<>(); if (exclusionPatterns != null) { for (IPath pattern : exclusionPatterns) { if (!path.equals(entry.getPath().append(pattern))) { exclusionList.add(pattern); } } } if ((inclusionPatterns == null || inclusionPatterns.length == inclusionList.size()) && (exclusionPatterns == null || exclusionPatterns.length == exclusionList.size())) { return entry; } else { return JavaCore.newSourceEntry(entry.getPath(), inclusionList.toArray(new IPath[0]), exclusionList.toArray(new IPath[0]), entry.getOutputLocation(), entry.getExtraAttributes()); } } }
private void addExclusionPatterns(IClasspathEntry newEntry, List existing, Set modifiedEntries) { IPath entryPath= newEntry.getPath(); for (int i= 0; i < existing.size(); i++) { IClasspathEntry curr= (IClasspathEntry) existing.get(i); IPath currPath= curr.getPath(); if (curr.getEntryKind() == IClasspathEntry.CPE_SOURCE && currPath.isPrefixOf(entryPath)) { IPath[] exclusionFilters= curr.getExclusionPatterns(); if (!JavaModelUtil.isExcludedPath(entryPath, exclusionFilters)) { IPath pathToExclude= entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator(); IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); newExclusionFilters[exclusionFilters.length]= pathToExclude; IClasspathEntry updated= JavaCore.newSourceEntry(currPath, newExclusionFilters, curr.getOutputLocation()); existing.set(i, updated); modifiedEntries.add(updated); } } } }
private void addExclusionPatterns(IClasspathEntry newEntry, List<IClasspathEntry> existing, Set<IClasspathEntry> modifiedEntries) { IPath entryPath= newEntry.getPath(); for (int i= 0; i < existing.size(); i++) { IClasspathEntry curr= existing.get(i); IPath currPath= curr.getPath(); if (curr.getEntryKind() == IClasspathEntry.CPE_SOURCE && currPath.isPrefixOf(entryPath)) { IPath[] exclusionFilters= curr.getExclusionPatterns(); if (!JavaModelUtil.isExcludedPath(entryPath, exclusionFilters)) { IPath pathToExclude= entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator(); IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); newExclusionFilters[exclusionFilters.length]= pathToExclude; IClasspathEntry updated= JavaCore.newSourceEntry(currPath, newExclusionFilters, curr.getOutputLocation()); existing.set(i, updated); modifiedEntries.add(updated); } } } }
private void addExclusionPatterns(IClasspathEntry newEntry, List<IClasspathEntry> existing, Set<IClasspathEntry> modifiedEntries) { IPath entryPath= newEntry.getPath(); for (int i= 0; i < existing.size(); i++) { IClasspathEntry curr= existing.get(i); IPath currPath= curr.getPath(); if (curr.getEntryKind() == IClasspathEntry.CPE_SOURCE && currPath.isPrefixOf(entryPath)) { IPath[] exclusionFilters= curr.getExclusionPatterns(); if (!JavaModelUtil.isExcludedPath(entryPath, exclusionFilters)) { IPath pathToExclude= entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator(); IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); newExclusionFilters[exclusionFilters.length]= pathToExclude; IClasspathEntry updated= JavaCore.newSourceEntry(currPath, newExclusionFilters, curr.getOutputLocation()); existing.set(i, updated); modifiedEntries.add(updated); } } } }
/** * Updates the new classpath with exclusion patterns for the specified path. * * @param entries * the classpath entries * @param path * the path */ private static void addExclusionPatterns(final List<IClasspathEntry> entries, final IPath path) { for (int index= 0; index < entries.size(); index++) { final IClasspathEntry entry= entries.get(index); if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().isPrefixOf(path)) { final IPath[] patterns= entry.getExclusionPatterns(); if (!JavaModelUtil.isExcludedPath(path, patterns)) { final IPath[] filters= new IPath[patterns.length + 1]; System.arraycopy(patterns, 0, filters, 0, patterns.length); filters[patterns.length]= path.removeFirstSegments(entry.getPath().segmentCount()).addTrailingSeparator(); entries.set(index, JavaCore.newSourceEntry(entry.getPath(), filters, entry.getOutputLocation())); } } } }
/** * Updates the new classpath with exclusion patterns for the specified path. * * @param entries * the classpath entries * @param path * the path */ private static void addExclusionPatterns(final List<IClasspathEntry> entries, final IPath path) { for (int index= 0; index < entries.size(); index++) { final IClasspathEntry entry= entries.get(index); if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().isPrefixOf(path)) { final IPath[] patterns= entry.getExclusionPatterns(); if (!JavaModelUtil.isExcludedPath(path, patterns)) { final IPath[] filters= new IPath[patterns.length + 1]; System.arraycopy(patterns, 0, filters, 0, patterns.length); filters[patterns.length]= path.removeFirstSegments(entry.getPath().segmentCount()).addTrailingSeparator(); entries.set(index, JavaCore.newSourceEntry(entry.getPath(), filters, entry.getOutputLocation())); } } } }
/** * Find out whether the <code>IResource</code> excluded or not. * * @param resource the resource to be checked * @param project the Java project * @return <code>true</code> if the resource is excluded, <code> * false</code> otherwise * @throws JavaModelException */ public static boolean isExcluded(IResource resource, IJavaProject project) throws JavaModelException { IPackageFragmentRoot root= getFragmentRoot(resource, project, null); if (root == null) return false; String fragmentName= getName(resource.getFullPath(), root.getPath()); fragmentName= completeName(fragmentName); IClasspathEntry entry= root.getRawClasspathEntry(); return entry != null && contains(new Path(fragmentName), entry.getExclusionPatterns(), null); }
/** * Find out whether the <code>IResource</code> excluded or not. * * @param resource the resource to be checked * @param project the Java project * @return <code>true</code> if the resource is excluded, <code> * false</code> otherwise * @throws JavaModelException */ public static boolean isExcluded(IResource resource, IJavaProject project) throws JavaModelException { IPackageFragmentRoot root= getFragmentRoot(resource, project, null); if (root == null) return false; String fragmentName= getName(resource.getFullPath(), root.getPath()); fragmentName= completeName(fragmentName); IClasspathEntry entry= root.getRawClasspathEntry(); return entry != null && contains(new Path(fragmentName), entry.getExclusionPatterns(), null); }
/** * Updates the new classpath with exclusion patterns for the specified path. * * @param entries * the classpath entries * @param path * the path */ private static void addExclusionPatterns(final List entries, final IPath path) { for (int index= 0; index < entries.size(); index++) { final IClasspathEntry entry= (IClasspathEntry) entries.get(index); if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().isPrefixOf(path)) { final IPath[] patterns= entry.getExclusionPatterns(); if (!JavaModelUtil.isExcludedPath(path, patterns)) { final IPath[] filters= new IPath[patterns.length + 1]; System.arraycopy(patterns, 0, filters, 0, patterns.length); filters[patterns.length]= path.removeFirstSegments(entry.getPath().segmentCount()).addTrailingSeparator(); entries.set(index, JavaCore.newSourceEntry(entry.getPath(), filters, entry.getOutputLocation())); } } } }
/** * Find out whether the <code>IResource</code> excluded or not. * * @param resource the resource to be checked * @param project the Java project * @return <code>true</code> if the resource is excluded, <code> * false</code> otherwise * @throws JavaModelException */ public static boolean isExcluded(IResource resource, IJavaProject project) throws JavaModelException { IPackageFragmentRoot root= getFragmentRoot(resource, project, null); if (root == null) return false; String fragmentName= getName(resource.getFullPath(), root.getPath()); fragmentName= completeName(fragmentName); IClasspathEntry entry= root.getRawClasspathEntry(); return entry != null && contains(new Path(fragmentName), entry.getExclusionPatterns(), null); }
private IClasspathEntry toClasspathEntry(EclipseSourceDirectory sourceFolder, IClasspathEntry existingEntry) { SourceFolderEntryBuilder builder = new SourceFolderEntryBuilder(this.project, existingEntry.getPath()); builder.setOutput(existingEntry.getOutputLocation()); builder.setAttributes(existingEntry.getExtraAttributes()); builder.setIncludes(existingEntry.getInclusionPatterns()); builder.setExcludes(existingEntry.getExclusionPatterns()); synchronizeAttributesFromModel(builder, sourceFolder); return builder.build(); }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }
private void saveClasspathEntry(IClasspathEntry entry) throws IOException { if (saveNewId(entry, this.classpathEntryIds)) { saveInt(entry.getContentKind()); saveInt(entry.getEntryKind()); savePath(entry.getPath()); savePaths(entry.getInclusionPatterns()); savePaths(entry.getExclusionPatterns()); savePath(entry.getSourceAttachmentPath()); savePath(entry.getSourceAttachmentRootPath()); savePath(entry.getOutputLocation()); this.out.writeBoolean(entry.isExported()); saveAccessRules(entry.getAccessRules()); this.out.writeBoolean(entry.combineAccessRules()); saveAttributes(entry.getExtraAttributes()); } }