Search in sources :

Example 6 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorTests method testHoverForPath.

public void testHoverForPath() 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, 9, 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$
    String correctResultRegEx = "<html><body text=\"#.*\" bgcolor=\"#.*\"><h5>Path Elements:</h5><ul><li>.*</html>";
    // $NON-NLS-1$
    assertTrue("Expected the following hover text to match regex: " + correctResultRegEx, hoverText.matches(correctResultRegEx));
}
Also used : AntEditor(org.eclipse.ant.internal.ui.editor.AntEditor) IFile(org.eclipse.core.resources.IFile) XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IRegion(org.eclipse.jface.text.IRegion)

Example 7 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorTests method testPatternSetHover.

public void testPatternSetHover() 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, 45, 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$
    String correctResult = "<h5>Includes:</h5><li>*.xml</li><p><p><h5>Excludes:</h5><li>**/*Test*</li></body></html>";
    // $NON-NLS-1$ //$NON-NLS-2$
    assertTrue("Expected the following hover text to end with: " + correctResult + "was: " + hoverText, hoverText.endsWith(correctResult));
}
Also used : AntEditor(org.eclipse.ant.internal.ui.editor.AntEditor) IFile(org.eclipse.core.resources.IFile) XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IRegion(org.eclipse.jface.text.IRegion)

Example 8 with XMLTextHover

use of org.eclipse.ant.internal.ui.editor.text.XMLTextHover in project eclipse.platform by eclipse-platform.

the class AntEditorTests method testHoverRegionWithSpaces.

public void testHoverRegionWithSpaces() 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);
    // in the middle of the "compile" target of the depends attribute
    int offset = getOffsetWithinLine(editor, 22, 39);
    IRegion region = hover.getHoverRegion(editor.getViewer(), offset);
    assertNotNull(region);
    IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    String text = doc.get(region.getOffset(), region.getLength());
    assertTrue(// $NON-NLS-1$ //$NON-NLS-2$
    "Region incorrect. Expected length of 7 and text of \"compile\", length was " + region.getLength() + " and text was " + text, // $NON-NLS-1$
    region.getLength() == 7 && "compile".equals(text));
}
Also used : AntEditor(org.eclipse.ant.internal.ui.editor.AntEditor) IFile(org.eclipse.core.resources.IFile) XMLTextHover(org.eclipse.ant.internal.ui.editor.text.XMLTextHover) IRegion(org.eclipse.jface.text.IRegion) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

XMLTextHover (org.eclipse.ant.internal.ui.editor.text.XMLTextHover)8 AntEditor (org.eclipse.ant.internal.ui.editor.AntEditor)7 IFile (org.eclipse.core.resources.IFile)7 IRegion (org.eclipse.jface.text.IRegion)7 AntInformationProvider (org.eclipse.ant.internal.ui.editor.text.AntInformationProvider)1 IDocument (org.eclipse.jface.text.IDocument)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 IInformationPresenter (org.eclipse.jface.text.information.IInformationPresenter)1 IInformationProvider (org.eclipse.jface.text.information.IInformationProvider)1 InformationPresenter (org.eclipse.jface.text.information.InformationPresenter)1 IEditorPart (org.eclipse.ui.IEditorPart)1