List of usage examples for org.eclipse.jdt.internal.core JarEntryDirectory setChildren
public void setChildren(IJarEntryResource[] children)
From source file:com.codenvy.ide.ext.java.server.internal.core.JarPackageFragment.java
License:Open Source License
/** * Compute all the non-java resources according to the given entry names. *///www . java 2 s . co m private Object[] computeNonJavaResources(ArrayList entryNames) { int length = entryNames.size(); if (length == 0) return JavaElementInfo.NO_NON_JAVA_RESOURCES; HashMap jarEntries = new HashMap(); // map from IPath to IJarEntryResource HashMap childrenMap = new HashMap(); // map from IPath to ArrayList<IJarEntryResource> ArrayList topJarEntries = new ArrayList(); for (int i = 0; i < length; i++) { String resName = (String) entryNames.get(i); // consider that a .java file is not a non-java resource (see bug 12246 Packages view shows .class and .java files when JAR has source) if (!com.codenvy.ide.ext.java.server.internal.core.util.Util.isJavaLikeFileName(resName)) { IPath filePath = new Path(resName); IPath childPath = filePath.removeFirstSegments(this.names.length); if (jarEntries.containsKey(childPath)) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=222665 continue; } JarEntryFile file = new JarEntryFile(filePath.lastSegment(), manager); jarEntries.put(childPath, file); if (childPath.segmentCount() == 1) { file.setParent(this); topJarEntries.add(file); } else { IPath parentPath = childPath.removeLastSegments(1); while (parentPath.segmentCount() > 0) { ArrayList parentChildren = (ArrayList) childrenMap.get(parentPath); if (parentChildren == null) { Object dir = new JarEntryDirectory(parentPath.lastSegment()); jarEntries.put(parentPath, dir); childrenMap.put(parentPath, parentChildren = new ArrayList()); parentChildren.add(childPath); if (parentPath.segmentCount() == 1) { topJarEntries.add(dir); break; } childPath = parentPath; parentPath = childPath.removeLastSegments(1); } else { parentChildren.add(childPath); break; // all parents are already registered } } } } } Iterator entries = childrenMap.entrySet().iterator(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry) entries.next(); IPath entryPath = (IPath) entry.getKey(); ArrayList entryValue = (ArrayList) entry.getValue(); JarEntryDirectory jarEntryDirectory = (JarEntryDirectory) jarEntries.get(entryPath); int size = entryValue.size(); IJarEntryResource[] children = new IJarEntryResource[size]; for (int i = 0; i < size; i++) { JarEntryResource child = (JarEntryResource) jarEntries.get(entryValue.get(i)); child.setParent(jarEntryDirectory); children[i] = child; } jarEntryDirectory.setChildren(children); if (entryPath.segmentCount() == 1) { jarEntryDirectory.setParent(this); } } return topJarEntries.toArray(new Object[topJarEntries.size()]); }
From source file:org.eclipse.che.jdt.internal.core.JarPackageFragment.java
License:Open Source License
/** * Compute all the non-java resources according to the given entry names. */// w w w.j a v a 2s . c om private Object[] computeNonJavaResources(ArrayList entryNames) { int length = entryNames.size(); if (length == 0) return JavaElementInfo.NO_NON_JAVA_RESOURCES; HashMap jarEntries = new HashMap(); // map from IPath to IJarEntryResource HashMap childrenMap = new HashMap(); // map from IPath to ArrayList<IJarEntryResource> ArrayList topJarEntries = new ArrayList(); for (int i = 0; i < length; i++) { String resName = (String) entryNames.get(i); // consider that a .java file is not a non-java resource (see bug 12246 Packages view shows .class and .java files when JAR has source) if (!org.eclipse.che.jdt.internal.core.util.Util.isJavaLikeFileName(resName)) { IPath filePath = new Path(resName); IPath childPath = filePath.removeFirstSegments(this.names.length); if (jarEntries.containsKey(childPath)) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=222665 continue; } JarEntryFile file = new JarEntryFile(filePath.lastSegment(), manager); jarEntries.put(childPath, file); if (childPath.segmentCount() == 1) { file.setParent(this); topJarEntries.add(file); } else { IPath parentPath = childPath.removeLastSegments(1); while (parentPath.segmentCount() > 0) { ArrayList parentChildren = (ArrayList) childrenMap.get(parentPath); if (parentChildren == null) { Object dir = new JarEntryDirectory(parentPath.lastSegment()); jarEntries.put(parentPath, dir); childrenMap.put(parentPath, parentChildren = new ArrayList()); parentChildren.add(childPath); if (parentPath.segmentCount() == 1) { topJarEntries.add(dir); break; } childPath = parentPath; parentPath = childPath.removeLastSegments(1); } else { parentChildren.add(childPath); break; // all parents are already registered } } } } } Iterator entries = childrenMap.entrySet().iterator(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry) entries.next(); IPath entryPath = (IPath) entry.getKey(); ArrayList entryValue = (ArrayList) entry.getValue(); JarEntryDirectory jarEntryDirectory = (JarEntryDirectory) jarEntries.get(entryPath); int size = entryValue.size(); IJarEntryResource[] children = new IJarEntryResource[size]; for (int i = 0; i < size; i++) { JarEntryResource child = (JarEntryResource) jarEntries.get(entryValue.get(i)); child.setParent(jarEntryDirectory); children[i] = child; } jarEntryDirectory.setChildren(children); if (entryPath.segmentCount() == 1) { jarEntryDirectory.setParent(this); } } return topJarEntries.toArray(new Object[topJarEntries.size()]); }
From source file:org.eclipse.jdt.internal.core.JarPackageFragment.java
License:Open Source License
/** * Compute all the non-java resources according to the given entry names. *///w w w . ja v a 2 s. c om private Object[] computeNonJavaResources(ArrayList entryNames) { int length = entryNames.size(); if (length == 0) return JavaElementInfo.NO_NON_JAVA_RESOURCES; HashMap jarEntries = new HashMap(); // map from IPath to IJarEntryResource HashMap childrenMap = new HashMap(); // map from IPath to ArrayList<IJarEntryResource> // GROOVY start boolean isInteresting = LanguageSupportFactory.isInterestingProject(this.getJavaProject().getProject()); // GROOVY end ArrayList topJarEntries = new ArrayList(); for (int i = 0; i < length; i++) { String resName = (String) entryNames.get(i); // consider that a .java file is not a non-java resource (see bug 12246 Packages view shows .class and .java files when JAR has source) // GROOVY start // we want to show uncompiled groovy scripts that are coming in from a jar file /* old { if (!Util.isJavaLikeFileName(resName)) { } new */ if ((!Util.isJavaLikeFileName(resName) || (isInteresting && LanguageSupportFactory.isInterestingSourceFile(resName)))) { // GROOVY end IPath filePath = new Path(resName); IPath childPath = filePath.removeFirstSegments(this.names.length); if (jarEntries.containsKey(childPath)) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=222665 continue; } JarEntryFile file = new JarEntryFile(filePath.lastSegment()); jarEntries.put(childPath, file); if (childPath.segmentCount() == 1) { file.setParent(this); topJarEntries.add(file); } else { IPath parentPath = childPath.removeLastSegments(1); while (parentPath.segmentCount() > 0) { ArrayList parentChildren = (ArrayList) childrenMap.get(parentPath); if (parentChildren == null) { Object dir = new JarEntryDirectory(parentPath.lastSegment()); jarEntries.put(parentPath, dir); childrenMap.put(parentPath, parentChildren = new ArrayList()); parentChildren.add(childPath); if (parentPath.segmentCount() == 1) { topJarEntries.add(dir); break; } childPath = parentPath; parentPath = childPath.removeLastSegments(1); } else { parentChildren.add(childPath); break; // all parents are already registered } } } } } Iterator entries = childrenMap.entrySet().iterator(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry) entries.next(); IPath entryPath = (IPath) entry.getKey(); ArrayList entryValue = (ArrayList) entry.getValue(); JarEntryDirectory jarEntryDirectory = (JarEntryDirectory) jarEntries.get(entryPath); int size = entryValue.size(); IJarEntryResource[] children = new IJarEntryResource[size]; for (int i = 0; i < size; i++) { JarEntryResource child = (JarEntryResource) jarEntries.get(entryValue.get(i)); child.setParent(jarEntryDirectory); children[i] = child; } jarEntryDirectory.setChildren(children); if (entryPath.segmentCount() == 1) { jarEntryDirectory.setParent(this); } } return topJarEntries.toArray(new Object[topJarEntries.size()]); }