Custom hovering in Xtext 2.10 - eclipse

I use Xtext 2.10.0.v201605250459 with Eclipse Neon 4.6.1 and want to implement custom hover texts like described in this tutorial. However it does not work (no custom text appears as expected, but the default one as handled by Xtext framework).
My implementation of the hover provider:
package demo.ui.hover
import org.eclipse.xtext.ui.editor.hover.html.DefaultEObjectHoverProvider
import org.eclipse.emf.ecore.EObject
class DemoEObjectHoverProvider extends DefaultEObjectHoverProvider
{
override protected getFirstLine(EObject o)
{
return "This is some demo text!"
}
}
Here is how I register it:
/*
* generated by Xtext 2.10.0
*/
package demo.ui
import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor
import demo.ui.hover.DemoEObjectHoverProvider
/**
* Use this class to register components to be used within the Eclipse IDE.
*/
#FinalFieldsConstructor
class DemoUiModule extends AbstractDemoUiModule
{
def bindIEObjectHoverProvider()
{
typeof(DemoEObjectHoverProvider)
}
}
Can you identify some error there?

your guice binding is wrong
def Class<? extends IEObjectHoverProvider> bindIEObjectHoverProvider() {
DemoEObjectHoverProvider
}
see https://www.eclipse.org/Xtext/documentation/302_configuration.html#dependency-injection for the conventions

Related

BaseFilter, SerializedTextFilter and more are missing after upgrade from ag-grid 18.1.2 to ag-grid-community 20.1.0

After upgrading from ag-grid 18.1.2 to ag-grid 20.1.0 (ag-grid-community), it is no longer possible to import BaseFilter, SerializedTextFilter, SerializedDateFilter, and SerializedNumberFilter.
I can see them in the git source code under dist/lib/filter (https://github.com/ag-grid/ag-grid/tree/master/dist/lib/filter) but they are not available in the code under node_modules/ag-grid-community after installation.
My app contains classes that extends BaseFilter, and it's using all of the mentioned interfaces. I have searched for answers online without luck.
The following works with ag-grid#18.1.2 but not with ag-grid-community#21.1.0. BaseFilter and SerializedTextFilter are not available to import
import { BaseFilter, IFilterParams, SerializedTextFilter } from 'ag-grid';
class CustomFilterComponent<P extends IFilterParams, M extends SerializedTextFilter>
extends BaseFilter<string, P, M> {
customInit(): void {
...
}
isFilterActive(): boolean {
...
}
....
}
I expected there to be information regarding these changes to the ag-grid library, and how to deal with it. I have not been able to find it.
I solved the problem by not extending BaseFilter, and using TextFilterModel, DateFilterModel, and NumberFilterModel instead of SerializedTextFilter, SerializedDateFilter, and SerializedNumberFilter, and using constants from SimpleFilter instead of BaseFilter.

Annotations on file classes

In my current code (Java), I'm doing some custom annotation processing using class-level Java annotations i.e. the annotations are #java.lang.annotation.Target({ElementType.TYPE}).
The target classes contain only static utility methods, so I used file-scoped functions in Kotlin. How do I add these annotations to the generated Kt class?
In Java:
// Utils.java
package com.example;
#MyCustomAspect
public void Utils {
public static void doStuff() {
System.out.println("Hello";
}
}
Now in Kotlin:
// Utils.kt
package com.example;
// ??? #MyCustomAspect ???
fun doStuff() {
System.out.println("Hello";
}
You can use AnnotationTarget.FILE to allow for Kotlin defined annotation to target the Kt class generated from a .kt file. Java defined annotation with target ElementType.TYPE can also be used to target Kotlin file class:
#file:MyCustomAspect
package org.example
#Target(AnnotationTarget.FILE)
annotation class MyCustomAspect
fun doStuff(){
}

Add TextField in a listView with the feature to update the model on exit using wicket 1.4

I'm trying to add TextField in a listView that can update a model on exit or after update the text on it.
I have received a wonderful solution for this listed bellow but it seems works
in wicket 6.7.0, I guess?
import org.apache.wicket.ajax.attributes.{ThrottlingSettings, AjaxRequestAttributes}
val detail = new TextField("detail", new PropertyModel[Meeting](meeting, "description"))
detail.add(new AjaxFormComponentUpdatingBehavior(("keyup")) {
protected def onUpdate(target: AjaxRequestTarget) {
meeting.salvarMeetingInfo(meeting)
}
protected override def updateAjaxAttributes(attributes: AjaxRequestAttributes) {
attributes.setThrottlingSettings(new ThrottlingSettings("thr", Duration.milliseconds(800.0)))
super.updateAjaxAttributes(attributes)
}
})
item.add(detail)
//Error messages
scala: object attributes is not a member of package org.apache.wicket.ajax
import org.apache.wicket.ajax.attributes.{ThrottlingSettings, AjaxRequestAttributes}
^
scala: not found: type AjaxRequestAttributes
protected override def updateAjaxAttributes(attributes: AjaxRequestAttributes) {
^
But I need to use wicket 1.4, so there is an similar implementation or solution of the code above for wicket 1.4?
Thanks for someone that could help me.
There is no updateAjaxAttributes method in 1.4 call method setThrottleDelay on the behaviour instead. See docs for the details.

How to import a custom package into Scala Play! Framework 2.0

I'm working in Play! Framework 2.0 with Scala on sublime text editor. I wanted to create some custom helpers which are just a few methods relating to the controller or goal. So I created a folder in the "app" directory called "helpers," for example I have a helper called SiteHelper.scala
in /app/helpers/SiteHelper.scala I start with
package helpers
class SiteHelper {
def method() = {}
}
Now in my controller I want to be able to do this: import helpers.SiteHelper
then use the method in my controller: SiteHelper.method()
When I try this I get a compilation error: "not found: value SiteHelper"
How can I use my helper classes in my controllers?
It seems you want to use an object instead of a class
package helpers
object SiteHelper {
def method() = {}
}
Then in you constroller:
import helpers.SiteHelper
object MyConstroller {
SiteHelper.method()
}

Writing to stdout from an Eclipse plugin

My aim is to extend the eclipse QuickFix component and automate the process of solving syntax errors. Basically, the QuickFix component provides a list of solutions and my task is to select the best possible fix and apply it to the buggy code. But, for now I've been requested to print the resolutions for a marker in the console. I've tried to work out a tutorial and I'm kind of stuck right now. The tutorial I've tried to workout is: http://www.informit.com/articles/article.aspx?p=370625&seqNum=21
I've first added the extension in my plugin.xml file
<extension point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
markerType="org.eclipse.core.resources.problemmarker"
class="org.eclipse.escript.quickfix.QuickFixer"/>
</extension>
Then i have created the two classes QuickFixer and QuickFix.
package quickfixer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator;
class QuickFixer implements IMarkerResolutionGenerator {
public IMarkerResolution[] getResolutions(IMarker arg0) {
try {
Object problem = arg0.getAttribute("Whatsup");
return new IMarkerResolution[] {
new QuickFix("Fix #1 for "+problem),
new QuickFix("Fix #2 for "+problem),
};
} catch(CoreException e) {
return new IMarkerResolution[0];
}
}
}
then the class QuickFix:
package quickfixer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IMarkerResolution;
public class QuickFix implements IMarkerResolution {
String label;
QuickFix(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
public void run(IMarker arg0) {
MessageDialog.openInformation(null, "QuickFix Demo",
"This quick-fix is not yet implemented");
System.out.println("Label: " + label);
}
}
I've managed to correct all the errors i encountered and then i have run the plugin.
I have not been able to get the label printed out in the console.Any suggestions???...
Using System.out is not a good idea. Check the relevant FAQ on why
you should avoid using standard output or standard error in your
plug-in
and use proper logging (or the debugger).