use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.
the class WorkbenchTestHelper method xtendFile.
public XtendFile xtendFile(String fileName, String content) throws Exception {
IFile file = createFile(fileName, content);
Resource resource = getResourceSet().createResource(uri(file));
resource.load(new StringInputStream(content), null);
assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size());
XtendFile xtendFile = (XtendFile) resource.getContents().get(0);
return xtendFile;
}
use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.
the class WorkbenchTestHelper method xtendFile.
public XtendFile xtendFile(IProject project, String fileName, String content) throws Exception {
IFile file = createFileImpl(project.getName() + "/src/" + fileName, content);
Resource resource = resourceSetProvider.get(project).createResource(uri(file));
resource.load(new StringInputStream(content), null);
assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size());
XtendFile xtendFile = (XtendFile) resource.getContents().get(0);
return xtendFile;
}
use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.
the class InsertionOffsetTest method checkMethodInsertionOffset.
protected void checkMethodInsertionOffset(final CharSequence model) {
try {
final String modelAsString = model.toString();
final int caretOffset = modelAsString.replace("$", "").indexOf("|");
final int expectedOffset = modelAsString.replace("|", "").indexOf("$");
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.parseHelper.parse(modelAsString.replace("|", "").replace("$", "")).getXtendTypes());
final XtendClass xtendClass = ((XtendClass) _head);
Resource _eResource = xtendClass.eResource();
final XtextResource xtextResource = ((XtextResource) _eResource);
final EObject caretElement = this._eObjectAtOffsetHelper.resolveContainedElementAt(xtextResource, caretOffset);
Assert.assertEquals(expectedOffset, this._insertionOffsets.getNewMethodInsertOffset(caretElement, xtendClass));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.Resource in project xtext-xtend by eclipse.
the class InsertionOffsetTest method checkFieldInsertionOffset.
protected void checkFieldInsertionOffset(final CharSequence model) {
try {
final String modelAsString = model.toString();
final int caretOffset = modelAsString.replace("$", "").indexOf("|");
final int expectedOffset = modelAsString.replace("|", "").indexOf("$");
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.parseHelper.parse(modelAsString.replace("|", "").replace("$", "")).getXtendTypes());
final XtendClass xtendClass = ((XtendClass) _head);
Resource _eResource = xtendClass.eResource();
final XtextResource xtextResource = ((XtextResource) _eResource);
final EObject caretElement = this._eObjectAtOffsetHelper.resolveContainedElementAt(xtextResource, caretOffset);
Assert.assertEquals(expectedOffset, this._insertionOffsets.getNewFieldInsertOffset(caretElement, xtendClass));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.emf.ecore.resource.Resource in project Palladio-Editors-Sirius by PalladioSimulator.
the class ApplyUnapplyProfileAction method execute.
@SuppressWarnings("unchecked")
@Override
public void execute(final Collection<? extends EObject> selections, final Map<String, Object> parameters) {
final EObject target = ((DSemanticDecorator) selections.iterator().next()).getTarget();
final Resource targetResource = target.eResource();
final FeatureEditorDialog profileSelectionDialog = new FeatureEditorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), LABEL_PROVIDER, target, target.eClass().getEAllStructuralFeatures().get(0).getEType(), ProfileAPI.getAppliedProfiles(targetResource), SELECT_APPLIED_PROFILES_MESSAGE, ProfileAPI.getApplicableProfiles(), false, true, true);
if (profileSelectionDialog.open() == Dialog.OK) {
ProfileAPI.updateProfileApplications(targetResource, (EList<Profile>) profileSelectionDialog.getResult());
}
}
Aggregations