use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorSourceViewerConfiguration method getInformationPresenter.
@Override
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator());
presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
IInformationProvider provider = new AntInformationProvider(new XMLTextHover(fEditor));
presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_CDATA);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_COMMENT);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_DTD);
presenter.setInformationProvider(provider, AntEditorPartitionScanner.XML_TAG);
presenter.setSizeConstraints(60, 10, true, true);
return presenter;
}
use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorTests method testHoverForProperty.
public void testHoverForProperty() throws PartInitException, BadLocationException {
// $NON-NLS-1$
IFile file = getIFile("refid.xml");
// $NON-NLS-1$
AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
XMLTextHover hover = new XMLTextHover(editor);
int offset = getOffsetWithinLine(editor, 42, 13);
IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
String hoverText = hover.getHoverInfo(editor.getViewer(), region);
// $NON-NLS-1$
assertNotNull("Expecting a hovertext object", hoverText);
// $NON-NLS-1$
String correctResult = "<p>value with spaces</body></html>";
// $NON-NLS-1$
assertTrue("Expected the following hover text to end with: " + correctResult, hoverText.endsWith(correctResult));
}
use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorTests method testBadPatternSetHover.
public void testBadPatternSetHover() throws PartInitException, BadLocationException {
// $NON-NLS-1$
IFile file = getIFile("refid.xml");
// $NON-NLS-1$
AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
XMLTextHover hover = new XMLTextHover(editor);
int offset = getOffsetWithinLine(editor, 46, 25);
IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
String hoverText = hover.getHoverInfo(editor.getViewer(), region);
// $NON-NLS-1$
assertNotNull("Expecting a hovertext object", hoverText);
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String correctResult = "Ant UI Tests" + File.separatorChar + "buildfiles" + File.separatorChar + "nothere not found.";
// $NON-NLS-1$
assertTrue("Expected the following hover text to ends with: " + correctResult, hoverText.endsWith(correctResult));
}
use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorTests method testAugmentOpenSelectHover.
/**
* Tests that the element augmented by the augment task properly displays the augmented elements when hovering
*
* @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=377075
* @throws Exception
*/
public void testAugmentOpenSelectHover() throws Exception {
// $NON-NLS-1$
IFile file = getIFile("bug377075.ent");
// $NON-NLS-1$
IEditorPart part = EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
// $NON-NLS-1$
assertTrue("The opened editor must be the AntEditor", part instanceof AntEditor);
AntEditor editor = (AntEditor) part;
int offset = getOffsetWithinLine(editor, 1, 11);
// select the 'path1' id for the path element
editor.selectAndReveal(offset, 5);
ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals("Selection is not correct", "path1", selection.getText());
XMLTextHover hover = new XMLTextHover(editor);
IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
// $NON-NLS-1$
assertNotNull("The selected region for the augmented element cannot be null", region);
String text = hover.getHoverInfo(editor.getViewer(), region);
// $NON-NLS-1$
assertNotNull("The hover text for the path element must not be null", text);
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("The hover text must contain the augmented element 'foo'", text.contains("foo"));
}
use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.
the class AntEditorTests method testFileSetHover.
public void testFileSetHover() throws PartInitException, BadLocationException {
// $NON-NLS-1$
IFile file = getIFile("refid.xml");
// $NON-NLS-1$
AntEditor editor = (AntEditor) EditorTestHelper.openInEditor(file, "org.eclipse.ant.ui.internal.editor.AntEditor", true);
XMLTextHover hover = new XMLTextHover(editor);
int offset = getOffsetWithinLine(editor, 44, 20);
IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
String hoverText = hover.getHoverInfo(editor.getViewer(), region);
// $NON-NLS-1$
assertNotNull("Expecting a hovertext object", hoverText);
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("Expected to see '<h5>Includes:</h5><li>include</li>'", hoverText.contains("<h5>Includes:</h5><li>include</li>"));
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("Expected to see '<h5>Excludes:</h5><li>exclude</li>'", hoverText.contains("<h5>Excludes:</h5><li>exclude</li>"));
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String text = "<li>**" + File.separator + "SCCS" + File.separator + "**</li>";
// $NON-NLS-1$
assertTrue("Expected to see '<li>**/SCCS/**</li>'", hoverText.contains(text));
// $NON-NLS-1$ //$NON-NLS-2$
text = "<li>**" + File.separator + ".DS_Store</li>";
// $NON-NLS-1$
assertTrue("Expected to see '<li>**/.DS_Store</li>'", hoverText.contains(text));
// $NON-NLS-1$ //$NON-NLS-2$
text = "<li>**" + File.separator + ".bzrignore</li>";
// $NON-NLS-1$
assertTrue("Expected to see '<li>**/.bzrignore</li>'", hoverText.contains(text));
// $NON-NLS-1$ //$NON-NLS-2$
text = "<li>**" + File.separator + ".gitattributes</li>";
// $NON-NLS-1$
assertTrue("Expected to see '<li>**/.gitattributes</li>'", hoverText.contains(text));
// $NON-NLS-1$ //$NON-NLS-2$
text = "<li>**" + File.separator + ".hgtags</li>";
// $NON-NLS-1$
assertTrue("Expected to see '<li>**/.hgtags</li>'", hoverText.contains(text));
}
Aggregations