private Object[] getPackageContents(IPackageFragment fragment) throws JavaScriptModelException { ISourceReference[] sourceRefs; if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE) { sourceRefs = fragment.getJavaScriptUnits(); } else { IClassFile[] classFiles = fragment.getClassFiles(); List topLevelClassFile = new ArrayList(); for (int i = 0; i < classFiles.length; i++) { IType type = classFiles[i].getType(); if (type != null && type.getDeclaringType() == null && !type.isAnonymous() && !type.isLocal()) topLevelClassFile.add(classFiles[i]); } sourceRefs = (ISourceReference[]) topLevelClassFile.toArray(new ISourceReference[topLevelClassFile.size()]); } Object[] result = new Object[0]; for (int i = 0; i < sourceRefs.length; i++) result = concatenate(result, removeImportAndPackageDeclarations(getChildren(sourceRefs[i]))); return concatenate(result, fragment.getNonJavaScriptResources()); }
/** Adds all of the openables defined within this package fragment to the list. */ private void injectAllOpenablesForPackageFragment( IPackageFragment packFrag, ArrayList openables) { try { IPackageFragmentRoot root = (IPackageFragmentRoot) packFrag.getParent(); int kind = root.getKind(); if (kind != 0) { boolean isSourcePackageFragment = (kind == IPackageFragmentRoot.K_SOURCE); if (isSourcePackageFragment) { IJavaScriptUnit[] cus = packFrag.getJavaScriptUnits(); for (int i = 0, length = cus.length; i < length; i++) { openables.add(cus[i]); } } else { IClassFile[] classFiles = packFrag.getClassFiles(); for (int i = 0, length = classFiles.length; i < length; i++) { openables.add(classFiles[i]); } } } } catch (JavaScriptModelException e) { // ignore } }