private void handleMultipleResults() { org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> list = null; Object temp = container.eGet(reference); if (temp instanceof org.eclipse.emf.common.util.EList<?>) { list = org.emftext.sdk.concretesyntax.resource.cs.util.CsCastUtil.cast(temp); } boolean first = true; for (org.emftext.sdk.concretesyntax.resource.cs.ICsReferenceMapping<ReferenceType> mapping : result.getMappings()) { if (first) { first = false; } else if (list != null) { addResultToList(mapping, proxy, list); } else { new org.emftext.sdk.concretesyntax.resource.cs.util.CsRuntimeUtil() .logError( container.eClass().getName() + "." + reference.getName() + " has multiplicity 1 but was resolved to multiple elements", null); } } }
protected < ContainerType extends org.eclipse.emf.ecore.EObject, ReferenceType extends org.eclipse.emf.ecore.EObject> void registerContextDependentProxy( final ASPM.resource.ASPM.mopp.ASPMContextDependentURIFragmentFactory< ContainerType, ReferenceType> factory, final ContainerType container, final org.eclipse.emf.ecore.EReference reference, final String id, final org.eclipse.emf.ecore.EObject proxy) { final int position; if (reference.isMany()) { position = ((java.util.List<?>) container.eGet(reference)).size(); } else { position = -1; } postParseCommands.add( new ASPM.resource.ASPM.IASPMCommand<ASPM.resource.ASPM.IASPMTextResource>() { public boolean execute(ASPM.resource.ASPM.IASPMTextResource resource) { if (resource == null) { // the resource can be null if the parser is used for code completion return true; } resource.registerContextDependentProxy( factory, container, reference, id, proxy, position); return true; } }); }
/** * This standard implementation searches the tree for objects of the correct type with a name * attribute matching the identifier. */ protected void resolve( String identifier, ContainerType container, org.eclipse.emf.ecore.EReference reference, int position, boolean resolveFuzzy, ssl.resource.ssl.ISslReferenceResolveResult<ReferenceType> result) { try { org.eclipse.emf.ecore.EClass type = reference.getEReferenceType(); org.eclipse.emf.ecore.EObject root = ssl.resource.ssl.util.SslEObjectUtil.findRootContainer(container); // first check whether the root element matches boolean continueSearch = checkElement(root, type, identifier, resolveFuzzy, true, result); if (!continueSearch) { return; } // then check the contents for (java.util.Iterator<org.eclipse.emf.ecore.EObject> iterator = root.eAllContents(); iterator.hasNext(); ) { org.eclipse.emf.ecore.EObject element = iterator.next(); continueSearch = checkElement(element, type, identifier, resolveFuzzy, true, result); if (!continueSearch) { return; } } org.eclipse.emf.ecore.resource.Resource resource = container.eResource(); if (resource != null) { org.eclipse.emf.common.util.URI uri = getURI(identifier, resource.getURI()); if (uri != null) { org.eclipse.emf.ecore.EObject element = loadResource(container.eResource().getResourceSet(), uri); if (element == null) { return; } checkElement(element, type, identifier, resolveFuzzy, false, result); } } } catch (java.lang.RuntimeException rte) { // catch exception here to prevent EMF proxy resolution from swallowing it rte.printStackTrace(); } }
public void loadContents() { // read from the class (operations and atributes) Debug.assert( getReference() != null, "my own ref null"); org.omg.CORBA.StructDef myReference = org.omg.CORBA.StructDefHelper.narrow( getReference()); Debug.assert( myReference != null, "narrow failed for " + getReference() ); /* load nested definitions from interfacePackage directory */ String[] classes = null; if( my_dir != null ) { classes = my_dir.list( new IRFilenameFilter(".class") ); // load class files in this interface's Package directory if( classes != null) { for( int j = 0; j < classes.length; j++ ) { try { org.jacorb.util.Debug.output(2, "Struct " +name+ " tries " + full_name.replace('.', fileSeparator) + "Package" + fileSeparator + classes[j].substring( 0, classes[j].indexOf(".class")) ); ClassLoader loader = getClass().getClassLoader(); if( loader == null ) { loader = RepositoryImpl.loader; } Class cl = loader.loadClass( ( full_name.replace('.', fileSeparator) + "Package" + fileSeparator + classes[j].substring( 0, classes[j].indexOf(".class")) ).replace( fileSeparator, '/') ); Contained containedObject = Contained.createContained( cl, path, myReference, containing_repository ); if( containedObject == null ) continue; org.omg.CORBA.Contained containedRef = Contained.createContainedReference(containedObject); if( containedObject instanceof ContainerType ) ((ContainerType)containedObject).loadContents(); containedRef.move( myReference, containedRef.name(), containedRef.version() ); org.jacorb.util.Debug.output(2, "Struct " + full_name + " loads "+ containedRef.name() ); contained.put( containedRef.name() , containedRef ); containedLocals.put( containedRef.name(), containedObject ); } catch ( Exception e ) { e.printStackTrace(); } } } } }
public PlateWorker(ContainerType containerType) { maxRow = containerType.getRowNo().intValue(); maxVolume = containerType.getColumnNo().intValue(); capacity = maxRow * maxVolume; }