This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.NullPointerException | |
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSettingDelegate(BasicEObjectImpl.java:1565) | |
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1027) | |
at org.neclipse.xtext.example.smalljava.smallJavaDsl.impl.ClassTypeImpl.eGet(ClassTypeImpl.java:120) | |
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1011) | |
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eGet(BasicEObjectImpl.java:1003) | |
at org.eclipse.emf.compare.utils.ReferenceUtil.safeEGet(ReferenceUtil.java:94) | |
at org.eclipse.emf.compare.diff.DefaultDiffEngine.computeSingleValuedAttributeDifferences(DefaultDiffEngine.java:1024) | |
at org.eclipse.emf.compare.diff.DefaultDiffEngine.computeDifferences(DefaultDiffEngine.java:575) | |
at org.eclipse.emf.compare.diff.DefaultDiffEngine.checkForDifferences(DefaultDiffEngine.java:151) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(URI.createURI("dummy.mydsl")) | |
resourceServiceProvider.get(Injector).injectMembers(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val resolver = new ClassloaderClasspathUriResolver() | |
val classpathURI = URI.createURI('''«ClasspathUriUtil.CLASSPATH_SCHEME»:/«packagePath»/«fileName»''') | |
val normalizedURI = resolver.resolve(this, classpathURI) /*resolver.resolve(null, classpathURI)*/ | |
val resource = new ResourceSetImpl().getResource(normalizedUri.trimFragment(), true) | |
if (resource.diagnostic != Diagnostic.OK_INSTANCE) { | |
throw new IllegalStateException("Problem parsing '" + uri + "':\n" + | |
Joiner.on('\n').join(resource.getErrors())); | |
} | |
resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val resolver = new BundleClasspathUriResolver() | |
val classpathUri = URI.createURI('''«ClasspathUriUtil.CLASSPATH_SCHEME»:/models/yourmodel.xcore''') | |
val normalizedUri = resolver.resolve(Platform.getBundle("org.ne.emf.xcore.models"), classpathUri) /*resolver.resolve(null, classpathURI)*/ | |
val resource = new ResourceSetImpl().getResource(normalizedUri.trimFragment(), true) | |
if (resource.diagnostic != Diagnostic.OK_INSTANCE) { | |
throw new IllegalStateException("Problem parsing '" + uri + "':\n" + | |
Joiner.on('\n').join(resource.getErrors())); | |
} | |
resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*TIP : Getting handle of services across DSL's using IGlobalServiceProvider*/ | |
// DSL Project | |
@Inject private IGlobalServiceProvider globalServiceProvider | |
val myLanguageIndex = globalServiceProvider.findService(URI.createURI("dummy.mylang"), MyLanguageIndex) | |
val myAnotherLanguageIndex = globalServiceProvider.findService(URI.createURI("dummy.anotherlang"), MyAnotherLanguageIndex) | |
// Non-DSL Project | |
val registry = IResourceServiceProvider.Registry.INSTANCE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyDslDocumentProvider extends XtextDocumentProvider { | |
@Override | |
protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) | |
throws CoreException { | |
try { | |
final IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); | |
service.executeCommand("org.eclipse.xtext.ui.FormatAction", null); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final XtextResourceSet xtextResourceSet = ... | |
final ResourceDescriptionsData resourceDescriptionsData = ResourceDescriptionsData.ResourceSetAdapter.findResourceDescriptionsData(xtextResourceSet); | |
if (resourceDescriptionsData != null) { | |
//resourceDescriptionsData.getAllResourceDescriptions() | |
//resourceDescriptionsData.getResourceDescription(uri) | |
//resourceDescriptionsData.getExportedObjectsByType(type) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean deliver = resourceSet.eDeliver(); | |
try { | |
// Disable notification delivery to the adapters | |
resourceSet.eSetDeliver(false); | |
// Make change to the resource set | |
resourceSet.getResources().clear(); | |
} finally { | |
// Reset the deliver flag to its previous state | |
resourceSet.eSetDeliver(deliver); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the URI to the resource | |
final URI uri = resource.getURI(); | |
// Get the resource resolved by the URI. Do not load the resource, only get one if exists | |
final Resource r = resourceSet.getResource(uri, false); | |
if (r != null) { | |
// Add the resource to the resourceset | |
resourceSet.getResources().add(resource); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eClass.getEPackage().getEFactoryInstance().create(eClass); |
OlderNewer