/** * Used to perform export/restriction propagation across referring projects/containers */ public ClasspathEntry combineWith(ClasspathEntry referringEntry) { if (referringEntry == null) return this; if (referringEntry.isExported() || referringEntry.getAccessRuleSet() != null ) { boolean combine = this.entryKind == CPE_SOURCE || referringEntry.combineAccessRules(); return new ClasspathEntry( getContentKind(), getEntryKind(), getPath(), this.inclusionPatterns, this.exclusionPatterns, getSourceAttachmentPath(), getSourceAttachmentRootPath(), getOutputLocation(), referringEntry.isExported() || this.isExported, // duplicate container entry for tagging it as exported combine(referringEntry.getAccessRules(), getAccessRules(), combine), this.combineAccessRules, this.extraAttributes); } // no need to clone return this; }
/** * Taken from {@link JavaProject#isOnClasspath(org.eclipse.core.resources.IResource)} * * @param classpath * @param newPath * @return */ private static boolean isAlreadyOnClasspath(Set classpath, IPath newPath) { for (Iterator itr = classpath.iterator(); itr.hasNext();) { IClasspathEntry entry = (IClasspathEntry) itr.next(); IPath entryPath = entry.getPath(); if (entryPath.equals(newPath)) { // package fragment roots must match exactly entry // pathes (no exclusion there) return true; } if (entryPath.isPrefixOf(newPath) && !Util.isExcluded(newPath, ((ClasspathEntry) entry).fullInclusionPatternChars(), ((ClasspathEntry) entry).fullExclusionPatternChars(), false)) { return true; } } return false; } }
for (int i = 0, length = resolvedClasspath.length; i < length; i++){ ClasspathEntry entry = (ClasspathEntry) resolvedClasspath[i]; if (excludeTestCode && entry.isTest()) { continue; if (isInitialProject || entry.isExported()){ String rootID = entry.rootID(); if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { boolean nestedWithoutTestCode = excludeTestCode || entry.isWithoutTestCode(); Boolean previousValue = rootIDs.get(rootID); ClasspathEntry combinedEntry; if (oldEntry.rootID().equals(rootID)) { accumulatedEntries.set(j, oldEntry.withExtraAttributeRemoved(IClasspathAttribute.WITHOUT_TEST_CODE)); break; combinedEntry = entry.combineWith(referringEntry); combinedEntry = entry.combineWith(referringEntry); accumulatedEntries.add(combinedEntry); IResource member = workspaceRoot.findMember(entry.getPath()); if (member != null && member.getType() == IResource.PROJECT){ // double check if bound to project (23977) IProject projRsc = (IProject) member; ClasspathEntry combinedEntry = entry.combineWith(referringEntry); accumulatedEntries.add(combinedEntry);
public ClasspathEntry resolvedDotDot(IPath reference) { IPath resolvedPath = resolveDotDot(reference, this.path); if (resolvedPath == this.path) return this; return new ClasspathEntry( getContentKind(), getEntryKind(), resolvedPath, this.inclusionPatterns, this.exclusionPatterns, getSourceAttachmentPath(), getSourceAttachmentRootPath(), getOutputLocation(), this.getReferencingEntry(), this.isExported, getAccessRules(), this.combineAccessRules, this.extraAttributes); }
public ClasspathEntry withExtraAttributeRemoved(String attrName) { IClasspathAttribute[] changedAttributes = Arrays.stream(this.getExtraAttributes()) .filter(a -> !a.getName().equals(attrName)).toArray(IClasspathAttribute[]::new); return new ClasspathEntry( this.getContentKind(), this.getEntryKind(), this.getPath(), this.getInclusionPatterns(), this.getExclusionPatterns(), this.getSourceAttachmentPath(), this.getSourceAttachmentRootPath(), this.getOutputLocation(), this.getReferencingEntry(), this.isExported(), this.getAccessRules(), this.combineAccessRules(), changedAttributes); }
if (this.contentKind != otherEntry.getContentKind()) return false; if (this.entryKind != otherEntry.getEntryKind()) return false; if (this.isExported != otherEntry.isExported()) return false; if (!this.path.equals(otherEntry.getPath())) return false; IPath otherPath = otherEntry.getSourceAttachmentPath(); if (this.sourceAttachmentPath == null) { if (otherPath != null) otherPath = otherEntry.getSourceAttachmentRootPath(); if (this.sourceAttachmentRootPath == null) { if (otherPath != null) if (!equalPatterns(this.inclusionPatterns, otherEntry.getInclusionPatterns())) return false; if (!equalPatterns(this.exclusionPatterns, otherEntry.getExclusionPatterns())) return false; AccessRuleSet otherRuleSet = otherEntry.getAccessRuleSet(); if (getAccessRuleSet() != null) { if (!getAccessRuleSet().equals(otherRuleSet)) return false; } else if (otherRuleSet != null)
NodeList children = element.getChildNodes(); boolean[] foundChildren = new boolean[children.getLength()]; String kindAttr = removeAttribute(TAG_KIND, attributes); String pathAttr = removeAttribute(TAG_PATH, attributes); int kind = kindFromString(kindAttr); if (kind != IClasspathEntry.CPE_VARIABLE && kind != IClasspathEntry.CPE_CONTAINER && !path.isAbsolute()) { if (!(path.segmentCount() > 0 && path.segment(0).equals(ClasspathEntry.DOT_DOT))) { ? new Path(removeAttribute(TAG_SOURCEPATH, attributes)) : null; if (kind != IClasspathEntry.CPE_VARIABLE && sourceAttachmentPath != null && !sourceAttachmentPath.isAbsolute()) { ? new Path(removeAttribute(TAG_ROOTPATH, attributes)) : null; boolean isExported = removeAttribute(TAG_EXPORTED, attributes).equals("true"); //$NON-NLS-1$ IPath[] inclusionPatterns = decodePatterns(attributes, TAG_INCLUDING); if (inclusionPatterns == null) inclusionPatterns = INCLUDE_ALL; IPath[] exclusionPatterns = decodePatterns(attributes, TAG_EXCLUDING); if (exclusionPatterns == null) exclusionPatterns = EXCLUDE_NONE; NodeList attributeList = getChildAttributes(TAG_ACCESS_RULES, children, foundChildren); IAccessRule[] accessRules = decodeAccessRules(attributeList); accessRules = getAccessRules(inclusionPatterns, exclusionPatterns);
for (int i = 0, length = resolvedClasspath.length; i < length; i++){ ClasspathEntry entry = (ClasspathEntry) resolvedClasspath[i]; if (isInitialProject || entry.isExported()){ String rootID = entry.rootID(); if (rootIDs.contains(rootID)) { continue; ClasspathEntry combinedEntry = entry.combineWith(referringEntry); accumulatedEntries.add(combinedEntry); if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) { IResource member = workspaceRoot.findMember(entry.getPath()); if (member != null && member.getType() == IResource.PROJECT){ // double check if bound to project (23977) IProject projRsc = (IProject) member;
IClasspathEntry currentEntry = rawClasspath[index]; if (currentEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { rawLibrariesPath.add(ClasspathEntry.resolveDotDot(getProject().getLocation(), currentEntry.getPath())); ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries(); for (int j = 0, length2 = extraEntries.length; j < length2; j++) { if (!rawLibrariesPath.contains(extraEntries[j].getPath())) { cEntry = cEntry.combineWith((ClasspathEntry) rawEntry); if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { cEntry = cEntry.resolvedDotDot(getProject().getLocation()); && result.rawReverseMap.get(cEntry.getPath()) == null) { ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries(); for (int k = 0, length2 = extraEntries.length; k < length2; k++) { if (!rawLibrariesPath.contains(extraEntries[k].getPath())) { addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives); resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot(getProject().getLocation()); ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries(); for (int k = 0, length2 = extraEntries.length; k < length2; k++) { if (!rawLibrariesPath.contains(extraEntries[k].getPath())) { addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, true, knownDrives);
NodeList attributeList = ClasspathEntry.getChildAttributes(ClasspathEntry.TAG_ATTRIBUTES, children, foundChildren); IClasspathAttribute[] extraAttributes = ClasspathEntry.decodeExtraAttributes(attributeList); attributeList = ClasspathEntry.getChildAttributes(ClasspathEntry.TAG_ACCESS_RULES, children, foundChildren); IAccessRule[] accessRules = ClasspathEntry.decodeAccessRules(attributeList); IClasspathEntry entry = JavaCore.newLibraryEntry(entryPath, sourceAttachPath, sourceAttachRootPath, accessRules, extraAttributes, false/*not exported*/); res.add(entry);
continue; cpEntry = cpEntry.combineWith((ClasspathEntry)referringEntry); access = cpEntry.getAccessRuleSet(); switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY:
Map rootToResolvedEntries) throws JavaModelException { String rootID = ((ClasspathEntry)resolvedEntry).rootID(); if (rootIDs.contains(rootID)) return; accumulatedRoots, rootIDs, rootToResolvedEntries == null ? resolvedEntry : ((ClasspathEntry)resolvedEntry).combineWith((ClasspathEntry) referringEntry), // only combine if need to build the reverse map retrieveExportedRoots, rootToResolvedEntries); accumulatedRoots.add(root); rootIDs.add(rootID); if (rootToResolvedEntries != null) rootToResolvedEntries.put(root, ((ClasspathEntry)resolvedEntry).combineWith((ClasspathEntry) referringEntry));
&& (sTokPaths.countTokens() == sTokEKinds.countTokens())) { while (sTokPaths.hasMoreTokens()) { IClasspathEntry entry = new ClasspathEntry(Integer
private static void decodeUnknownNode(Node node, StringBuffer buffer, IJavaProject project) { ByteArrayOutputStream s = new ByteArrayOutputStream(); OutputStreamWriter writer; try { writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$ XMLWriter xmlWriter = new XMLWriter(writer, project, false/*don't print XML version*/); decodeUnknownNode(node, xmlWriter, true/*insert new line*/); xmlWriter.flush(); xmlWriter.close(); buffer.append(s.toString("UTF8")); //$NON-NLS-1$ } catch (UnsupportedEncodingException e) { // ignore (UTF8 is always supported) } }
public char[][] fullExclusionPatternChars() { try { if (isOpen() && getKind() != IPackageFragmentRoot.K_SOURCE) return null; ClasspathEntry entry = (ClasspathEntry) getRawClasspathEntry(); if (entry == null) { return null; } else { return entry.fullExclusionPatternChars(); } } catch (JavaModelException e) { return null; } }
public static class ClasspathResolutionBreakpointListener { public void breakpoint(int bp) { // override in listener implementation } }
public char[][] fullInclusionPatternChars() { try { if (isOpen() && getKind() != IPackageFragmentRoot.K_SOURCE) return null; ClasspathEntry entry = (ClasspathEntry)getRawClasspathEntry(); if (entry == null) { return null; } else { return entry.fullInclusionPatternChars(); } } catch (JavaModelException e) { return null; } } public String getElementName() {
public static class ClasspathResolutionBreakpointListener { public void breakpoint(int bp) { // override in listener implementation } }
if (this.contentKind != otherEntry.getContentKind()) return false; if (this.entryKind != otherEntry.getEntryKind()) return false; if (this.isExported != otherEntry.isExported()) return false; if (!this.path.equals(otherEntry.getPath())) return false; IPath otherPath = otherEntry.getSourceAttachmentPath(); if (this.sourceAttachmentPath == null) { if (otherPath != null) otherPath = otherEntry.getSourceAttachmentRootPath(); if (this.sourceAttachmentRootPath == null) { if (otherPath != null) if (!equalPatterns(this.inclusionPatterns, otherEntry.getInclusionPatterns())) return false; if (!equalPatterns(this.exclusionPatterns, otherEntry.getExclusionPatterns())) return false; AccessRuleSet otherRuleSet = otherEntry.getAccessRuleSet(); if (getAccessRuleSet() != null) { if (!getAccessRuleSet().equals(otherRuleSet)) return false; } else if (otherRuleSet != null)
public ClasspathEntry resolvedDotDot(IPath reference) { IPath resolvedPath = resolveDotDot(reference, this.path); if (resolvedPath == this.path) return this; return new ClasspathEntry( getContentKind(), getEntryKind(), resolvedPath, this.inclusionPatterns, this.exclusionPatterns, getSourceAttachmentPath(), getSourceAttachmentRootPath(), getOutputLocation(), this.getReferencingEntry(), this.isExported, getAccessRules(), this.combineAccessRules, this.extraAttributes); }