use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-eclipse by eclipse.
the class DerivedResourceMarkerCopier method getMaxSeverity.
private int getMaxSeverity(IFile srcFile) {
URI resourceURI = URI.createPlatformResourceURI(srcFile.getFullPath().toString(), true);
IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(resourceURI);
if (serviceProvider == null)
return Integer.MAX_VALUE;
IssueSeveritiesProvider severitiesProvider = serviceProvider.get(IssueSeveritiesProvider.class);
Severity severity = severitiesProvider.getIssueSeverities(new ResourceImpl(resourceURI)).getSeverity(COPY_JAVA_PROBLEMS_ISSUECODE);
switch(severity) {
case WARNING:
return IMarker.SEVERITY_WARNING;
case ERROR:
return IMarker.SEVERITY_ERROR;
case INFO:
case IGNORE:
return Integer.MAX_VALUE;
default:
break;
}
return Integer.MAX_VALUE;
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-eclipse by eclipse.
the class JdtBasedSimpleTypeScopeProviderTest method setUp.
@Before
public void setUp() throws Exception {
projectProvider = new MockJavaProjectProvider();
factory = new JdtTypeProviderFactory(projectProvider);
IQualifiedNameConverter qualifiedNameConverter = new IQualifiedNameConverter.DefaultImpl();
scopeProvider = new JdtBasedSimpleTypeScopeProvider(factory, qualifiedNameConverter);
resourceSet = new ResourceSetImpl();
resource = new ResourceImpl();
resource.setURI(URI.createURI("http://does/not/exist.file"));
emptyResource = new ResourceImpl();
emptyResource.setURI(URI.createURI("http://does/not/exist.file2"));
resourceSet.getResources().add(emptyResource);
resourceSet.getResources().add(resource);
field = TypesFactory.eINSTANCE.createJvmField();
resource.getContents().add(field);
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project dsl-devkit by dsldevkit.
the class ShortFragmentProviderTest method testLongFragment.
@Test
@BugTest(value = "DSL-601")
public void testLongFragment() {
int reps = 100;
EObject root = EcoreUtil.create(testClass);
EObject parent = root;
for (int i = 0; i < reps; i++) {
EObject child = EcoreUtil.create(testClass);
parent.eSet(testReference, child);
parent = child;
}
ResourceImpl resource = new ResourceImpl();
resource.getContents().add(root);
String fragment = fragmentProvider.getFragment(parent, fragmentFallback);
Assert.assertEquals("/0*" + (reps + 1), fragment);
Assert.assertEquals(parent, fragmentProvider.getEObject(resource, fragment, fragmentFallback));
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project InformationSystem by ObeoNetwork.
the class ExportAsSQLScriptsAction method exportComparison.
public void exportComparison(final Comparison comparison) {
final IResource containingFolder = getContainingFolder(comparison);
if (containingFolder == null) {
// No containing folder means the user aborted the export action
return;
}
final File targetFolder = getTargetfolder(containingFolder);
if (targetFolder == null) {
return;
}
// Initialize a resourceset to be sure the model is contained within a resource (or Acceleo will throw a NPE)
ResourceSet set = new ResourceSetImpl();
Resource resource = new ResourceImpl();
resource.getContents().add(comparison);
set.getResources().add(resource);
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
try {
DatabaseGen databaseGen = new DatabaseGen(comparison, targetFolder, Collections.emptyList());
databaseGen.doGenerate(new BasicMonitor());
} catch (IOException e) {
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "SQL Generation", "A problem occured during the generation. See Error Log view for more details.");
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
// Refreshing the target folder
try {
containingFolder.getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
Activator.getDefault().getLog().log(status);
}
}
};
// Launch operation
try {
PlatformUI.getWorkbench().getProgressService().run(true, false, operation);
} catch (Exception e) {
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "SQL Generation", "A problem occured during the generation. See Error Log view for more details.");
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
}
}
use of org.eclipse.emf.ecore.resource.impl.ResourceImpl in project xtext-core by eclipse.
the class DeclarativeValidatorTest method testExceptionWhenGivenWrongEObject.
@Test
public void testExceptionWhenGivenWrongEObject() {
AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
@Check
public void foo(Object x) {
warning("Error Message", EcorePackage.Literals.EANNOTATION, EcorePackage.Literals.ENAMED_ELEMENT__NAME, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, "42");
}
};
BasicDiagnostic chain = new BasicDiagnostic();
Resource r = new ResourceImpl(URI.createURI("http://foo"));
EObject x = EcoreFactory.eINSTANCE.createEAttribute();
r.getContents().add(x);
try {
test.validate(x, chain, Collections.emptyMap());
fail("expected exception");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations