本文整理匯總了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;
}
示例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);
}
示例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;
}
示例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();
}
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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));
}
}
示例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;
}
示例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;
}
示例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;
}