當前位置: 首頁>>代碼示例>>Java>>正文


Java EcoreUtil.resolveAll方法代碼示例

本文整理匯總了Java中org.eclipse.emf.ecore.util.EcoreUtil.resolveAll方法的典型用法代碼示例。如果您正苦於以下問題:Java EcoreUtil.resolveAll方法的具體用法?Java EcoreUtil.resolveAll怎麽用?Java EcoreUtil.resolveAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.ecore.util.EcoreUtil的用法示例。


在下文中一共展示了EcoreUtil.resolveAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getScriptErrors

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
protected List<Diagnostic> getScriptErrors(Script script) {
	EcoreUtil.resolveAll(script.eResource());
	List<Diagnostic> diagnostics = super.getScriptErrors(script);
	Iterator<Expression> expressions = Iterators.filter(EcoreUtil2.eAll(script), Expression.class);
	List<Diagnostic> result = Lists.<Diagnostic> newArrayList(Iterables.filter(diagnostics,
			ExceptionDiagnostic.class));
	while (expressions.hasNext()) {
		Expression expression = expressions.next();
		RuleEnvironment ruleEnvironment = RuleEnvironmentExtensions.newRuleEnvironment(expression);
		Result<TypeRef> type = typeSystem.type(ruleEnvironment, expression);
		if (type.getRuleFailedException() != null) {
			Throwable cause = Throwables.getRootCause(type.getRuleFailedException());
			if (!(cause instanceof RuleFailedException)) {
				if (cause instanceof Exception) {
					result.add(new ExceptionDiagnostic((Exception) cause));
				} else {
					throw new RuntimeException(cause);
				}
			}
		}
	}
	validator.validate(script.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
	return result;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:26,代碼來源:ExceptionAnalyser.java

示例2: SelectAnyEObjectDialog

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
public SelectAnyEObjectDialog(Shell parent, ResourceSet resourceSet, ILabelProvider renderer) {
	super(parent, renderer);
	_searchedResourceSet = resourceSet;
	ArrayList<EObject> all = new ArrayList<EObject>();
	EcoreUtil.resolveAll(resourceSet);
	for (Resource r : _searchedResourceSet.getResources())
	{
		for (TreeIterator<EObject> iterator = r.getAllContents(); iterator.hasNext();) {
			EObject o =  iterator.next();
			if(select(o)) all.add(o);
		}
	}
	
	Object[] elements = all.toArray();
	this.setElements(elements);
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:17,代碼來源:SelectAnyEObjectDialog.java

示例3: getEcoreModel

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
protected ResourceSet getEcoreModel(File ecorefile) {

        ResourceSetImpl rs = new ResourceSetImpl();
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
        try {
            URI fileUri = URI.createFileURI(ecorefile.getCanonicalPath());
            Resource resource = rs.createResource(fileUri);
            resource.load(null);
            EcoreUtil.resolveAll(resource);
            rs.getResources().add(resource);
            EcoreUtil.resolveAll(rs);

        } catch (IOException e) {
            e.printStackTrace();
        }
        return rs;
    }
 
開發者ID:datathings,項目名稱:greycat-idea-plugin,代碼行數:18,代碼來源:PrettyPrinter.java

示例4: convertERDSLtoXMI

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
public static void convertERDSLtoXMI(String inputM, String outputM) {
	Injector injector = new QueryITStandaloneSetup().createInjectorAndDoEMFRegistration();

	XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);


	URI uri = URI.createURI(inputM);
	

	Resource xtextResource = resourceSet.getResource(uri, true);

	EcoreUtil.resolveAll(xtextResource);

	Resource xmiResource = resourceSet.createResource(URI.createURI(outputM));
	xmiResource.getContents().add(xtextResource.getContents().get(0));
	try {
		xmiResource.save(null);
		System.out.println("Saved " + outputM);
    	System.out.println("QueryIT file converted successfully to XMI");
    	System.out.println("-------------------------------------");
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:TodorovicNikola,項目名稱:SurveyDSL,代碼行數:25,代碼來源:QueryITToXMIConverter.java

示例5: invokeInternal

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
		Issues issues) {
	ResourceSet resourceSet = getResourceSet();

	// due to some Xcore peculiarity we have to access the IAllContainerState here
	// to trigger some lazy init logic
	IAllContainersState allContainerState = (IAllContainersState) EcoreUtil.getAdapter(resourceSet.eAdapters(),
			IAllContainersState.class);
	allContainerState.isEmpty("");

	Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes,
			new Predicate<URI>() {
		@Override
		public boolean apply(URI input) {
			return input.fileExtension().equals(XCORE_FILE_EXT);
		}
	});
	List<Resource> resources = new ArrayList<>();
	for (URI uri : uris.values()) {
		LOGGER.info(uri);
		try {
			resources.add(parse(uri, resourceSet));
		} catch (Exception e) {
			LOGGER.error("Problem during loading of resource @ " + uri, e);
		}
	}
	installIndex(resourceSet);
	for (Resource r : resources) {
		EcoreUtil.resolveAll(r);
		for (Diagnostic x : r.getErrors()) {
			issues.addError(x.getMessage(), x);
		}

	}
	ctx.set(slot, resources);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:38,代碼來源:XcoreReader.java

示例6: testResolveAllBuiltInTypes

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@SuppressWarnings("javadoc")
@Test
public void testResolveAllBuiltInTypes() {
	BuiltInTypeScope scope = BuiltInTypeScope.get(resourceSet);
	scope.getSingleElement(QualifiedName.create("any")); // trigger loading
	Assert.assertEquals(5, resourceSet.getResources().size());
	EcoreUtil.resolveAll(resourceSet);
	Assert.assertEquals(5, resourceSet.getResources().size());

	Map<EObject, Collection<Setting>> unresolvedProxies = EcoreUtil.UnresolvedProxyCrossReferencer
			.find(resourceSet);
	Assert.assertTrue(unresolvedProxies.toString(), unresolvedProxies.isEmpty());
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:BuiltInTypeScopeTest.java

示例7: postProcessN4JSResource

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private void postProcessN4JSResource(N4JSResource resource, CancelIndicator cancelIndicator) {
	// step 1: process the AST (resolve all proxies in AST, infer type of all typable AST nodes, etc.)
	astProcessor.processAST(resource, cancelIndicator);
	// step 2: expose internal types visible from outside
	// (i.e. if they are referenced from a type that is visible form the outside)
	exposeReferencedInternalTypes(resource);
	// step 3: resolve remaining proxies in TModule
	// (the TModule was created programmatically, so it usually does not contain proxies; however, in case of
	// explicitly declared types, the types builder copies type references from the AST to the corresponding
	// TModule element *without* resolving proxies, so the TModule might contain lazy-cross-ref proxies; most of
	// these should have been resolved during AST traversal and exposing internal types, but some can be left)
	EcoreUtil.resolveAll(resource.getModule());
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:14,代碼來源:N4JSPostProcessor.java

示例8: doAdd

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
protected void doAdd(EObject primaryTarget, TargetURIs targetURIsAddHere) {
	Resource resource = primaryTarget.eResource();
	// If the target is not contained in a resource, we cannot do anything but return.
	if (resource == null)
		return;
	EcoreUtil.resolveAll(primaryTarget.eResource());

	// Special handling for composed members and TStructMember
	if (primaryTarget instanceof TMember && ((TMember) primaryTarget).isComposed()) {
		// In case of composed member, add the constituent members instead.
		List<TMember> constituentMembers = ((TMember) primaryTarget).getConstituentMembers();
		for (TMember constituentMember : constituentMembers) {
			super.doAdd(constituentMember, targetURIsAddHere);
		}
	} else {
		if (primaryTarget instanceof TStructMember) {
			TStructMember crossRefStructMember = ((TStructMember) primaryTarget).getDefinedMember();
			if (crossRefStructMember != null)
				// If this TStructMember is an AST, also add the defined member located in the TModule
				super.doAdd(((TStructMember) primaryTarget).getDefinedMember(), targetURIsAddHere);
		}
		super.doAdd(primaryTarget, targetURIsAddHere);
	}

	inferredElements.collectInferredElements(primaryTarget, (object) -> {
		if (object != null) {
			super.doAdd(object, targetURIsAddHere);
		}
	}, projectUtils);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:32,代碼來源:InferredElementsTargetURICollector.java

示例9: findLaunchConfig

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
 * Finds a launch configuration with the given name from the current EMF index. The index contains all
 * launch configurations from projects that have the Xtext nature. Launch configurations from projects
 * without the Xtext nature are not found. Use {@link #findLaunchConfig(String, IFile)} in this case.
 *
 * @param name the name of the configuration to find
 * @return the configuration or <code>null</code>
 */
public LaunchConfig findLaunchConfig(String name) {
    Iterable<IEObjectDescription> indexed = index.getExportedObjectsByType(LcDslPackage.eINSTANCE.getLaunchConfig());

    for (IEObjectDescription o : indexed) {
        if (o.getName().getLastSegment().equals(name)) {
            EObject obj = EcoreUtil.resolve(o.getEObjectOrProxy(), rsProvider.get());
            EcoreUtil.resolveAll(obj);
            return (LaunchConfig) obj;
        }
    }
    return null;
}
 
開發者ID:mduft,項目名稱:lcdsl,代碼行數:21,代碼來源:LcDslHelper.java

示例10: getResources

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private EList<Resource> getResources() {
	ResourceSet rs = new ResourceSetImpl();
	URI inputURI = URI.createPlatformResourceURI(_context.getInputFile().getFullPath().toString(), true);
	Resource r = rs.getResource(inputURI, true);
	EcoreUtil.resolveAll(r);
	EcoreUtil.resolveAll(rs); // result in the load of several resources
	return rs.getResources();
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:9,代碼來源:ResourceMerger.java

示例11: getRootElement

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
public static EObject getRootElement(ResourceSet resourceSet, IFile file) {
	URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
	System.out.println("file " + file.getFullPath().toString());
	System.out.println("uri " + uri);
	org.eclipse.emf.ecore.resource.Resource resource = resourceSet.getResource(uri, true);
	EcoreUtil.resolveAll(resource);
	return resource.getContents().get(0);
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:9,代碼來源:OcciHelper.java

示例12: doSaveDocument

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite)
		throws CoreException {
	try {
		//System.out.println("doSaveDocument ");
		ResourceSet resourceSet = createResourceSet();
		XtextResource xtextResource = (XtextResource) resourceSet.createResource(URI.createURI("temp.occi"));
		InputStream is = new ByteArrayInputStream(document.get().getBytes());
		xtextResource.load(is, Collections.EMPTY_MAP);
		is.close();
		URI uri = URI.createPlatformResourceURI(
				((org.eclipse.ui.part.FileEditorInput) element).getFile().getFullPath().toString(), true);
		//resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
		//System.out.println("uriii "+uri);
		Resource xmiResource = resourceSet.getResource(uri, true);
		((XMLResource) xmiResource).getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER,
				new URIHandlerImpl.PlatformSchemeAware());
		xmiResource.getContents().clear();
		xmiResource.getContents().addAll(xtextResource.getContents());
		// SUPER IMPORTANT to avoid to have references to temp.occi
		EcoreUtil.resolveAll(xmiResource);			
		xmiResource.save(Collections.EMPTY_MAP);
	} catch (IOException e) {
		throw new CoreException(
				new Status(IStatus.ERROR, "org.occiware.clouddesigner.occi.xtext.ui", "Failed to save", e));
	}
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:28,代碼來源:OCCIDocumentProvider.java

示例13: loadModelURI

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
public static Resource loadModelURI(URI uri, ResourceSet rs) throws IOException {
	Resource res = rs.createResource(uri);
	res.load(null);
	EcoreUtil.resolveAll(rs);// IMPORTANT
	return res;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:7,代碼來源:EMFUtil.java

示例14: loadModelPath

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
public static Resource loadModelPath(String path, ResourceSet rs) throws IOException {
	Resource res = rs.createResource(EMFUtil.createFileURI(path));
	res.load(null);
	EcoreUtil.resolveAll(rs);// IMPORTANT
	return res;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:7,代碼來源:EMFUtil.java

示例15: loadModelThenConfigureResourceSet

import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private static Resource loadModelThenConfigureResourceSet(ResourceSet rs, URI modelURI, HashMap<String, String> nsURIMapping,
		SubMonitor subMonitor) {

	Resource resource = rs.getResource(modelURI, true);
	EcoreUtil.resolveAll(rs);
	configureResourceSet(rs,modelURI,nsURIMapping,subMonitor);

	return resource;

}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:11,代碼來源:DefaultModelLoader.java


注:本文中的org.eclipse.emf.ecore.util.EcoreUtil.resolveAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。