use of org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover in project xtext-eclipse by eclipse.
the class AbstractCompositeHoverTest method testMultipleHovers.
@SuppressWarnings("deprecation")
@Test
public void testMultipleHovers() {
final ITextHover hover1 = new ITextHover() {
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
// TODO Auto-generated method stub
if (offset == 0)
return new Region(offset, 0);
return null;
}
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
return "hover1";
}
};
final ITextHover hover2 = new ITextHover() {
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
// TODO Auto-generated method stub
if (offset == 1)
return new Region(offset, 0);
return null;
}
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
return "hover2";
}
};
AbstractCompositeHover hover = new AbstractCompositeHover() {
@Override
protected List<ITextHover> createHovers() {
List<ITextHover> hovers = Lists.newArrayList();
hovers.add(hover1);
hovers.add(hover2);
return hovers;
}
};
assertEquals(2, hover.getHovers().size());
assertNotNull(hover.getHoverRegion(editor.getInternalSourceViewer(), 0));
assertEquals("hover1", hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(0, 0)));
assertNotNull(hover.getHoverRegion(editor.getInternalSourceViewer(), 1));
assertEquals("hover2", hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(1, 0)));
}
use of org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover in project xtext-eclipse by eclipse.
the class AbstractCompositeHoverTest method testNullHoverList.
@SuppressWarnings("deprecation")
@Test
public void testNullHoverList() {
AbstractCompositeHover hover = new AbstractCompositeHover() {
@Override
protected List<ITextHover> createHovers() {
return null;
}
};
assertEquals(null, hover.getHovers());
assertNull(hover.getHoverRegion(editor.getInternalSourceViewer(), 0));
assertNull(hover.getHoverControlCreator());
assertNull(hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(0, 0)));
assertNull(hover.getHoverInfo2(editor.getInternalSourceViewer(), new Region(0, 0)));
}
use of org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover in project xtext-eclipse by eclipse.
the class AbstractCompositeHoverTest method testEmptyHoverList.
@SuppressWarnings("deprecation")
@Test
public void testEmptyHoverList() {
AbstractCompositeHover hover = new AbstractCompositeHover() {
@Override
protected List<ITextHover> createHovers() {
List<ITextHover> hovers = Lists.newArrayList();
return hovers;
}
};
assertEquals(0, hover.getHovers().size());
assertNull(hover.getHoverRegion(editor.getInternalSourceViewer(), 0));
assertNull(hover.getHoverControlCreator());
assertNull(hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(0, 0)));
assertNull(hover.getHoverInfo2(editor.getInternalSourceViewer(), new Region(0, 0)));
}
use of org.eclipse.xtext.ui.editor.hover.AbstractCompositeHover in project xtext-eclipse by eclipse.
the class AbstractCompositeHoverTest method testSingleHover.
@SuppressWarnings("deprecation")
@Test
public void testSingleHover() {
AbstractCompositeHover hover = new AbstractCompositeHover() {
@Override
protected List<ITextHover> createHovers() {
List<ITextHover> hovers = Lists.newArrayList();
hovers.add(new ITextHover() {
@Override
public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
// TODO Auto-generated method stub
if (offset == 0)
return new Region(offset, 0);
return null;
}
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
return "test";
}
});
return hovers;
}
};
assertEquals(1, hover.getHovers().size());
assertNotNull(hover.getHoverRegion(editor.getInternalSourceViewer(), 0));
assertEquals("test", hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(0, 0)));
assertNull(hover.getHoverRegion(editor.getInternalSourceViewer(), 5));
assertNull(hover.getHoverInfo(editor.getInternalSourceViewer(), new Region(0, 0)));
}
Aggregations