Analogue to <e4view> for command handlers - eclipse-plugin

I am writing a plugin for the Eclipse IDE and have registered (in my plugin.xml) an E4 part using the <e4view> element of the rg.eclipse.ui.views extension point. However, I fail to see how I can register an E4 command handler (#Execute method rather than AbstractHandler base class) in a similar fashion.
Is this possible somehow?

Related

How to intercept JUnit5 method annotated with #Disabled?

I would like to write a JUnit5 Extension where I have to take some action when a test method annotated with #Disabled is found. Unfortunately, beforeTestExecution() is not called for such methods. Does anybody have an idea how to intercept such #Disabled test methods ?
Thanks !
As described in the User Guide, you can disable the built-in ExecutionCondition that handles #Disabled by default by setting junit.jupiter.conditions.deactivate to org.junit.*DisabledCondition (see Configuration Parameters on how to set it). This will cause your tests to be executed.
Next, you need to implement your own ExecutionCondition extension, check for #Disabled, take your action and return ConditionEvaluationResult.disabled("...").
In order to avoid having to register your extension on each test class, you can activate Automatic Extension Registration and register your extension globally.
Depending on what you want to achieve, it may be easier to register your own TestExecutionListener (see Plugging in Your Own Test Execution Listeners) and implement executionSkipped().
The extension point used here is https://github.com/junit-team/junit5/blob/master/junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ExecutionCondition.java
It might be interesting to find out how several implementors compose, i.e. if the 2nd one will be called at all and under what circumstances. You’ll probably have to dive into Jupiter code or do some experiments.

modify a Kotlin class

I'd like to write a plugin for Intellij IDEA that should modify a Java and Kotlin code.
I use the method
PsiClass.getMethods()
in order to get all methods of Java and Kotlin classes. So far so good, so then I use methods like
PsiClass.add(), PsiClass.addAfter(), PsiClass.addBefore()
that all work fine once they are called on Java files, but start to throw an exception
IncorrectOperationException
once I called them on a Kotlin class.
I'd appreciate any hint on how I can modify Kotlin and Java classes (preferably using the same approach).
When you search for a Kotlin class via the JavaPsiFacade, it returns the light class which is a shallow representation that is just based on the information in the class file. In order to add PSI elements, you have to call navigationElement on it. Then, IJ will parse the source and build a full PSI tree that can be modified.
However, if the class is a Kotlin class, navigationElement will return a KtClass which is not derived from PsiClass. You will have to use the facilities in the Kotlin hierarchy to modify it. Method instances in Kotlin are also not instances of PsiMethod, but instances of KtMethod.
For analyzing Java and Kotlin sources in a common fashion there is a different syntax tree called "UAST", but for modifications you need a language-specific approach.

RFT build proxy on custom GUI (SWT) component

I have an SWT project, where are several custom GUI elements, and i try to find a way, to build some kind of proxy on top of them, like the default ones built on top of Labels, Texts, etc. Is there a way to do this? It would be really convenient, to create a custom GuiTestObject subclass, and use it (make RFT use it?) to identify these custom GUI elements, like KTable for example, because now these controls are handled by the best class known by RFT, like Composite or ScrolledComposite, so it's impossible to expose the custom properties of these classes for testing, and the best way to test these elements is by image comparison.
If this is not possible, then is there a way, to somehow get a reference to the actual ui component from a GuiTestObject? I tried in debug mode, but it looks like, that the reference is intentionally hidden somehow. Is there a way, to bypass this, and somehow access the reference? (I couldn't see the actual ui element neither using the debugger, nor using reflection).
Any help is greatly appreciated!
The TestObject that you have available in the script should represent the actual object in the AUT.
As you said the methods exposed to the script would be limited to what is provided by the TestObject however RFT has API called "invoke" that you can use to invoke some method directly on the control.
You should find more info on invoke here: Using Invoke in RFT
Second , you should be able to extend an Existing proxy using the Proxy SDK of RFT where you can add custom behavior for the proxies
You can get more info aobut proxy SDK here:
Proxy SDK in RFT

Register a method as a listener with aspectj

I already know how to intercept a method execution, but in this case, I will not call the method directly, it should be called when an event is fired (Observer pattern). How can i register that method as a listener using aspectj?
AspectJ as well as the AJDT for Eclipse contain code examples, including one implementing the Observer design pattern. Go to the AspectJ documentation page, select Examples and from there download the source code archive.

Track/intercept method call

I want to intercept a method call (usually .net API).
How can this be achived?
I have seen AOP/ContextBoundObject by some googling, but all those requires the class to be derived from ContextBoundObject.
I want to intercept MessageBox.Show Which i cannot modify.
The only way I know is by using run-time weaving. In .NET the only project I'm familiar with that does that is CThru built on top a commercial product called Typemock Isolator (I've used to work there)