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
/** | |
* In the implementation of the scope provider, we create a nested scope, where each scope contains the fields from the given Clazz. | |
**/ | |
override IScope getScope(EObject context, EReference eReference) { | |
if (reference == MyDslPackage.Literals.REF_TO_FIELD_FIELD) { | |
return clazzScope(context.getContainerOfType(Clazz)); | |
} | |
return super.getScope(context, eReference); |
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
// https://wiki.eclipse.org/ATL/EMFTVM#API | |
ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv(); | |
ResourceSet rs = new ResourceSetImpl(); | |
// Load metamodels | |
Metamodel metaModel = EmftvmFactory.eINSTANCE.createMetamodel(); | |
metaModel.setResource(rs.getResource(URI.createURI("http://www.eclipse.org/m2m/atl/2011/EMFTVM"), true)); | |
env.registerMetaModel("METAMODEL", metaModel); |
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
Runtime.getRuntime().addShutdownHook(new Thread(() -> { | |
// Your code comes here... | |
})); | |
/* addShutdownHook() - A shutdown hook is simply an initialized but unstarted thread. When the virtual machine begins its | |
shutdown sequence it will start all registered shutdown hooks in some unspecified order and let them run concurrently. When all the | |
hooks have finished it will then run all uninvoked finalizers if finalization-on-exit has been enabled. Finally, the virtual machine | |
will halt. Note that daemon threads will continue to run during the shutdown sequence, as will non-daemon threads if shutdown was | |
initiated by invoking the exitmethod. */ |
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
Data race: It occurs when synchronization is not used to coordinate access to the shared state. You risk data race whenever you write to a shared variable that might next be read by another thread, or read a variable that might have last been written by another thread, if both threads do not use synchronization | |
Race condition: It occurs when the correctness of a computation depends on the relative timing of interlaving of multiple threads by the runtime; in other words, when getting the right answer relies on the lucky timing. |
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
private static ClassLoader getBundleClassLoader(String name) { | |
Bundle bundle = Platform.getBundle(name); | |
BundleWiring wiring = bundle.adapt(BundleWiring.class); | |
wiring != null : String.format("Should not happen; current state of bundle %s is %s", | |
bundle.getSymbolicName(), bundle.getState()); | |
return wiring.getClassLoader(); | |
} |
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
https://stackoverflow.com/questions/9090500/how-to-compare-that-sequence-of-doubles-are-all-approximately-equal-in-java |
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
Behavior of EMF when proxy resolution is turned on - It is only when proxy resolution is enabled on a containment reference that the container and contained objects can reside in different resources. In this situation, adding an object to a resource’s contents does not automatically remove it from its existing container. this behavior is only available beginning in EMF 2.2. | |
Also, when generating a model, "containment proxies "must be enabled explicitly for the whole model, or else all containment references will be considered non-proxy-resolving, completely disabling cross-resource containment. | |
Previous to EMF 2.2, you could always be sure that the resource of an EObject in a containment tree would also be the resource of its container. Enabling cross-resource containment breaks this assumption, which could impact existing applications. For example, saving an object’s resource does not guarantee that its contents are saved. |
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 URIConverter converter = new URIConverterImpl(); | |
final URI uri1 = URI.createURI("http://www.example.com/epo2.ecore"); | |
final URI uri2 = URI.createURI("platform:/resource/models/epo2.ecore"); | |
// Maintain mapping between the two URI's | |
converter.getURIMap().put(uri1, uri2); | |
// Normalize/Convert the URI from one format into another | |
final URI normalized = converter.normalize(uri1); | |
System.out.println(normalized); |
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 Bundle bundle = Platform.getBundle("org.eclipse.ui.editors"); | |
final URL url = FileLocator.find(bundle, new Path("icons/full/obj16/quick_fix_warning_obj.png"), null); | |
final ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url); | |
final Image image = imageDesc.createImage(); | |
return image; |
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
https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged |