protected BinaryModule readBinaryModule(AbstractClassFile classFile, HashMap newElements, IBinaryModule modDecl) { this.binaryChildren = JavaElement.NO_ELEMENTS; this.typeParameters = TypeParameter.NO_TYPE_PARAMETERS; if (modDecl != null) {//may not be a valid class file // TODO: The following needs fix once we can get ModuleDeclaration from IndexBinaryType char[] modName = modDecl.name(); BinaryModule handle = new BinaryModule(classFile, new String(modName)); ModuleDescriptionInfo moduleInfo = ModuleDescriptionInfo.createModule(modDecl); setModule(handle); newElements.put(handle, moduleInfo); this.binaryChildren = new JavaElement[] { handle }; return handle; } return null; } /**
@Override public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) { switch (token.charAt(0)) { case JEM_MODULE: if (!memento.hasMoreTokens()) return this; String modName = memento.nextToken(); JavaElement mod = new BinaryModule(this, modName); return mod.getHandleFromMemento(memento, owner); } return null; } /**
@Override public IJavaElement getHandleFromMemento(String token, MementoTokenizer memento, WorkingCopyOwner owner) { switch (token.charAt(0)) { case JEM_MODULE: if (!memento.hasMoreTokens()) return this; String modName = memento.nextToken(); JavaElement mod = new BinaryModule(this, modName); return mod.getHandleFromMemento(memento, owner); } return null; } /**
/** * Creates the single child element for this class file adding the resulting * new handle (of type {@link IBinaryModule}) and info object to the newElements table. * Returns true if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ @Override protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryModule moduleInfo = getBinaryModuleInfo(); if (moduleInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(JavaElement.NO_ELEMENTS); return false; } // Create & link a handle: BinaryModule module = new BinaryModule(this, moduleInfo); newElements.put(module, moduleInfo); info.setChildren(new IJavaElement[] {module}); this.binaryModule = module; if (info instanceof ClassFileInfo) { ((ClassFileInfo) info).setModule(module); } ((PackageFragmentRootInfo) getPackageFragmentRoot().getElementInfo()).setModule(module); return true; }