本文整理汇总了Java中org.eclipse.emf.ecore.resource.ResourceSet.getResources方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceSet.getResources方法的具体用法?Java ResourceSet.getResources怎么用?Java ResourceSet.getResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.resource.ResourceSet
的用法示例。
在下文中一共展示了ResourceSet.getResources方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectTransitivelyDependentResources
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private List<Resource> collectTransitivelyDependentResources(XtextResource resource,
Set<URI> deltaURIs) {
List<Resource> result = Lists.newArrayList();
ResourceSet resourceSet = resource.getResourceSet();
for (Resource candidate : resourceSet.getResources()) {
if (candidate != resource) {
URI uri = candidate.getURI();
if (deltaURIs.contains(uri)) {
// the candidate is contained in the delta list
// schedule it for unloading
result.add(candidate);
} else if (candidate instanceof N4JSResource) {
// the candidate does depend on one of the changed resources
// schedule it for unloading
if (canLoadFromDescriptionHelper.dependsOnAny(candidate, deltaURIs)) {
result.add(candidate);
}
}
}
}
return result;
}
示例2: getElements
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private List<Resource> getElements(ResourceSet resSet, final List<Object> result) {
final List<Resource> ignoredResources = new ArrayList<>();
for (Resource res : new ArrayList<>(resSet.getResources())) {
final boolean isFirstResource = result.isEmpty();
// only show contents of first resource + .n4js resources
// (avoid showing built-in types or letting graph become to large)
String uriStr = res.getURI().toString();
if (isFirstResource || uriStr.endsWith(".n4js") || uriStr.endsWith(".n4jsd")) {
getElementsForN4JSs(result, res);
} else if (SHOW_BUILT_IN.length > 0
&& (uriStr.endsWith("builtin_js.n4ts") || uriStr.endsWith("builtin_n4.n4ts"))) {
getElementsForBuiltIns(result, ignoredResources, res);
} else {
// ignore the resource
ignoredResources.add(res);
}
}
return ignoredResources;
}
示例3: getGroup
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
private Group getGroup() {
final Group res;
final IEditorPart editor = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage()
.getActiveEditor();
if (editor instanceof IEditingDomainProvider) {
final EditingDomain editingDomain = ((IEditingDomainProvider) editor)
.getEditingDomain();
final ResourceSet resourceSet = editingDomain.getResourceSet();
Group group = null;
for (Resource resource : resourceSet.getResources()) {
for (EObject eObj : resource.getContents()) {
if (eObj instanceof Group) {
group = (Group) eObj;
break;
}
}
}
res = group;
} else {
res = null;
}
return res;
}
示例4: getResources
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的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();
}
示例5: organizeImports
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
* Give the result as a multiline diff. If cancellation due to multiple possible resolution is expected, provide the
* expected Exception with 'XPECT organizeImports ambiguous "Exception-Message" -->'.
*
* If the parameter is not provided, always the first computed solution in the list will be taken
*
* @param ambiguous
* - String Expectation in {@link BreakException}
*/
@ParameterParser(syntax = "('ambiguous' arg0=STRING)?")
@Xpect
@ConsumedIssues({ Severity.INFO, Severity.ERROR, Severity.WARNING })
public void organizeImports(
String ambiguous, // arg0
@StringDiffExpectation(whitespaceSensitive = false, allowSingleSegmentDiff = false, allowSingleLineDiff = false) IStringDiffExpectation expectation,
@ThisResource XtextResource resource) throws Exception {
logger.info("organize imports ...");
boolean bAmbiguityCheck = ambiguous != null && ambiguous.trim().length() > 0;
Interaction iaMode = bAmbiguityCheck ? Interaction.breakBuild : Interaction.takeFirst;
try {
if (expectation == null /* || expectation.isEmpty() */) {
// TODO throw exception if empty.
// Hey, I want to ask the expectation if it's empty.
// Cannot access the region which could be asked for it's length.
throw new AssertionFailedError(
"The test is missing a diff: // XPECT organizeImports --> [old string replaced|new string expected] ");
}
// capture text for comparison:
String beforeApplication = resource.getParseResult().getRootNode().getText();
N4ContentAssistProcessorTestBuilder fixture = n4ContentAssistProcessorTestBuilderHelper
.createTestBuilderForResource(resource);
IXtextDocument xtextDoc = fixture.getDocument(resource, beforeApplication);
// in case of cross-file hyperlinks, we have to make sure the target resources are fully resolved
final ResourceSet resSet = resource.getResourceSet();
for (Resource currRes : new ArrayList<>(resSet.getResources())) {
N4JSResource.postProcess(currRes);
}
// Calling organize imports
Display.getDefault().syncExec(
() -> imortsOrganizer.unsafeOrganizeDocument(xtextDoc, iaMode));
if (bAmbiguityCheck) {
// should fail if here
assertEquals("Expected ambiguous resolution to break the organize import command.", ambiguous, "");
}
// checking that no errors are left.
String textAfterApplication = xtextDoc.get();
// compare with expectation, it's a multiline-diff expectation.
String before = XpectCommentRemovalUtil.removeAllXpectComments(beforeApplication);
String after = XpectCommentRemovalUtil.removeAllXpectComments(textAfterApplication);
expectation.assertDiffEquals(before, after);
} catch (Exception exc) {
if (exc instanceof RuntimeException && exc.getCause() instanceof BreakException) {
String breakMessage = exc.getCause().getMessage();
assertEquals(ambiguous, breakMessage);
} else {
throw exc;
}
}
}
示例6: loadModel
import org.eclipse.emf.ecore.resource.ResourceSet; //导入方法依赖的package包/类
/**
* Common private method to load a model with or without animation.
*
* @param context
* The ExecutionContext of the GEMOC execution, to access the
* model URI, the melange query, etc.
* @param withAnimation
* True if the model should be loaded with animation, false
* otherwise.
* @return the loaded Resource
* @throws RuntimeException
* if anything goes wrong (eg. the model cannot be found)
*/
private static Resource loadModel(IExecutionContext context, boolean withAnimation, IProgressMonitor progressMonitor) throws RuntimeException {
// Common part: preparing URI + resource set
SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 10);
boolean useMelange = context.getRunConfiguration().getMelangeQuery() != null
&& !context.getRunConfiguration().getMelangeQuery().isEmpty();
URI modelURI = null;
if (useMelange) {
subMonitor.setTaskName("Loading model with melange");
modelURI = context.getRunConfiguration().getExecutedModelAsMelangeURI();
} else {
subMonitor.setTaskName("Loading model without melange");
modelURI = context.getRunConfiguration().getExecutedModelURI();
}
HashMap<String, String> nsURIMapping = getnsURIMapping(context);
ResourceSet resourceSet = createResourceSet(modelURI, nsURIMapping, subMonitor);
// If there is animation, we ask sirius to create the resource
if (withAnimation && context.getRunConfiguration().getAnimatorURI() != null) {
try {
// Killing + restarting Sirius session for animation
killPreviousSiriusSession(context.getRunConfiguration().getAnimatorURI());
openNewSiriusSession(context, context.getRunConfiguration().getAnimatorURI(), resourceSet, modelURI,
subMonitor,nsURIMapping);
// At this point Sirius has loaded the model, we just need to
// find it
for (Resource r : resourceSet.getResources()) {
if (r.getURI().equals(modelURI)) {
return r;
}
}
} catch (CoreException e) {
throw new RuntimeException("The model could not be loaded.", e);
}
throw new RuntimeException("The model could not be loaded.");
}
// If there is no animation, we create a resource ourselves
else {
return loadModelThenConfigureResourceSet(resourceSet, modelURI, nsURIMapping, subMonitor);
}
}