/** * Determines whether the inclusion filter of the element's source folder is empty * or not * @return <code>true</code> if the inclusion filter is empty, * <code>false</code> otherwise. * @throws JavaModelException */ public static boolean includeFiltersEmpty(IResource resource, IJavaProject project, IProgressMonitor monitor) throws JavaModelException { if (monitor == null) monitor= new NullProgressMonitor(); try { monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_ExamineInputFilters, 4); IPackageFragmentRoot root= getFragmentRoot(resource, project, new SubProgressMonitor(monitor, 4)); if (root != null) { IClasspathEntry entry= root.getRawClasspathEntry(); return entry.getInclusionPatterns().length == 0; } return true; } finally { monitor.done(); } }
/** * Determines whether the inclusion filter of the element's source folder is empty * or not * @param resource * @param project * @param monitor * @return <code>true</code> if the inclusion filter is empty, * <code>false</code> otherwise. * @throws JavaModelException */ public static boolean includeFiltersEmpty(IResource resource, IJavaProject project, IProgressMonitor monitor) throws JavaModelException { if (monitor == null) monitor= new NullProgressMonitor(); try { monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_ExamineInputFilters, 4); IPackageFragmentRoot root= getFragmentRoot(resource, project, new SubProgressMonitor(monitor, 4)); if (root != null) { IClasspathEntry entry= root.getRawClasspathEntry(); return entry.getInclusionPatterns().length == 0; } return true; } finally { monitor.done(); } }
/** * Determines whether the inclusion filter of the element's source folder is empty * or not * @param resource * @param project * @param monitor * @return <code>true</code> if the inclusion filter is empty, * <code>false</code> otherwise. * @throws JavaModelException */ public static boolean includeFiltersEmpty(IResource resource, IJavaProject project, IProgressMonitor monitor) throws JavaModelException { if (monitor == null) monitor= new NullProgressMonitor(); try { monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_ExamineInputFilters, 4); IPackageFragmentRoot root= getFragmentRoot(resource, project, new SubProgressMonitor(monitor, 4)); if (root != null) { IClasspathEntry entry= root.getRawClasspathEntry(); return entry.getInclusionPatterns().length == 0; } return true; } finally { monitor.done(); } }
/** * 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; }
protected void setIgnoreOptionalProblems(String entryPath, IProgressMonitor monitor) throws JavaModelException { final IJavaProject jaxWsProject = getJaxWsProject(); final IClasspathEntry[] rawClasspathEntries = jaxWsProject.getRawClasspath(); final List<IClasspathEntry> newEntries = new ArrayList<>(rawClasspathEntries.length); final org.eclipse.core.runtime.Path entryPathToSearch = new org.eclipse.core.runtime.Path('/' + jaxWsProject.getElementName() + '/' + entryPath); for (IClasspathEntry entry : rawClasspathEntries) { if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getPath().equals(entryPathToSearch)) { IClasspathAttribute[] origAttributes = entry.getExtraAttributes(); List<IClasspathAttribute> newAttributes = new ArrayList<>(origAttributes.length + 1); for (IClasspathAttribute attrib : origAttributes) { if (!IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS.equals(attrib.getName())) { newAttributes.add(attrib); } } newAttributes.add(JavaCore.newClasspathAttribute(IClasspathAttribute.IGNORE_OPTIONAL_PROBLEMS, Boolean.TRUE.toString())); newEntries.add(JavaCore.newSourceEntry(entry.getPath(), entry.getInclusionPatterns(), entry.getExclusionPatterns(), entry.getOutputLocation(), newAttributes.toArray(new IClasspathAttribute[newAttributes.size()]))); } else { newEntries.add(entry); } } jaxWsProject.setRawClasspath(newEntries.toArray(new IClasspathEntry[newEntries.size()]), monitor); }
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()); } } }
/** * Determines whether the current selection (of type * <code>ICompilationUnit</code> or <code>IPackageFragment</code>) * is on the inclusion filter of it's parent source folder. * * @param selection the current Java element * @param project the Java project * @param monitor progress monitor, can be <code>null</code> * @return <code>true</code> if the current selection is included, * <code>false</code> otherwise. * @throws JavaModelException */ public static boolean isIncluded(IJavaElement selection, IJavaProject project, IProgressMonitor monitor) throws JavaModelException { if (monitor == null) monitor= new NullProgressMonitor(); try { monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_ContainsPath, 4); IPackageFragmentRoot root= (IPackageFragmentRoot) selection.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IClasspathEntry entry= root.getRawClasspathEntry(); if (entry == null) return false; return contains(selection.getPath().removeFirstSegments(root.getPath().segmentCount()), entry.getInclusionPatterns(), new SubProgressMonitor(monitor, 2)); } finally { monitor.done(); } }
/** * Determines whether the current selection (of type * <code>ICompilationUnit</code> or <code>IPackageFragment</code>) * is on the inclusion filter of it's parent source folder. * * @param selection the current Java element * @param project the Java project * @param monitor progress monitor, can be <code>null</code> * @return <code>true</code> if the current selection is included, * <code>false</code> otherwise. * @throws JavaModelException */ public static boolean isIncluded(IJavaElement selection, IJavaProject project, IProgressMonitor monitor) throws JavaModelException { if (monitor == null) monitor= new NullProgressMonitor(); try { monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_ContainsPath, 4); IPackageFragmentRoot root= (IPackageFragmentRoot) selection.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); IClasspathEntry entry= root.getRawClasspathEntry(); if (entry == null) return false; return contains(selection.getPath().removeFirstSegments(root.getPath().segmentCount()), entry.getInclusionPatterns(), new SubProgressMonitor(monitor, 2)); } finally { monitor.done(); } }
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()); } }
protected IClasspathEntry copy(IClasspathEntry entry) throws JavaModelException { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); case IClasspathEntry.CPE_LIBRARY: try { return JavaCore.newLibraryEntry(this.destination, entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } catch (ClasspathEntry.AssertionFailedException e) { IJavaModelStatus status = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage()); throw new JavaModelException(status); } case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), entry.getExtraAttributes(), entry.isExported()); case IClasspathEntry.CPE_SOURCE: return JavaCore.newSourceEntry(this.destination, entry.getInclusionPatterns(), entry.getExclusionPatterns(), entry.getOutputLocation(), entry.getExtraAttributes()); case IClasspathEntry.CPE_VARIABLE: try { return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } catch (ClasspathEntry.AssertionFailedException e) { IJavaModelStatus status = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage()); throw new JavaModelException(status); } default: throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, getElementToProcess())); } } @Override
protected IClasspathEntry copy(IClasspathEntry entry) throws JavaModelException { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); case IClasspathEntry.CPE_LIBRARY: try { return JavaCore.newLibraryEntry(this.destination, entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } catch (ClasspathEntry.AssertionFailedException e) { IJavaModelStatus status = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage()); throw new JavaModelException(status); } case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), entry.getExtraAttributes(), entry.isExported()); case IClasspathEntry.CPE_SOURCE: return JavaCore.newSourceEntry(this.destination, entry.getInclusionPatterns(), entry.getExclusionPatterns(), entry.getOutputLocation(), entry.getExtraAttributes()); case IClasspathEntry.CPE_VARIABLE: try { return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } catch (ClasspathEntry.AssertionFailedException e) { IJavaModelStatus status = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage()); throw new JavaModelException(status); } default: throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, getElementToProcess())); } } public IJavaModelStatus verify() {
protected IClasspathEntry copy(IClasspathEntry entry) throws JavaModelException { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); case IClasspathEntry.CPE_LIBRARY: try { return JavaCore.newLibraryEntry(this.destination, entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } catch (ClasspathEntry.AssertionFailedException e) { IJavaModelStatus status = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage()); throw new JavaModelException(status); } case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), entry.getExtraAttributes(), entry.isExported()); case IClasspathEntry.CPE_SOURCE: return JavaCore.newSourceEntry(this.destination, entry.getInclusionPatterns(), entry.getExclusionPatterns(), entry.getOutputLocation(), entry.getExtraAttributes()); case IClasspathEntry.CPE_VARIABLE: try { return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), entry.getExtraAttributes(), entry.isExported()); } catch (ClasspathEntry.AssertionFailedException e) { IJavaModelStatus status = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage()); throw new JavaModelException(status); } default: throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, getElementToProcess())); } } public IJavaModelStatus verify() {