Search in sources :

Example 1 with SpecfileElement

use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.

the class SpecfileLabelProvider method getText.

@Override
public String getText(Object element) {
    // $NON-NLS-1$
    String str = "";
    if (element instanceof SpecfileSection) {
        SpecfileSection specfileSection = (SpecfileSection) element;
        str = specfileSection.toString();
    } else if (element instanceof Specfile) {
        str = ((Specfile) element).getName();
    } else if (element instanceof SpecfilePackageContainer) {
        str = Messages.SpecfileLabelProvider_0;
    } else if (element instanceof SpecfilePreamble) {
        str = Messages.SpecfileLabelProvider_1;
    } else if (element instanceof SpecfileElement) {
        SpecfileElement specfileElement = (SpecfileElement) element;
        str = specfileElement.getName();
    } else if (element instanceof String) {
        str = (String) element;
    } else if (element instanceof SpecfilePackage) {
        str = ((SpecfilePackage) element).getName();
    }
    return filterMacros(str.trim());
}
Also used : Specfile(org.eclipse.linuxtools.rpm.ui.editor.parser.Specfile) SpecfileSection(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileSection) SpecfileElement(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement) SpecfilePreamble(org.eclipse.linuxtools.internal.rpm.ui.editor.parser.SpecfilePreamble) SpecfilePackage(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackage) SpecfilePackageContainer(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackageContainer)

Example 2 with SpecfileElement

use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.

the class SpecfileQuickOutlineDialog method gotoSelectedElement.

private void gotoSelectedElement() {
    final SpecfileElement curElement = (SpecfileElement) getSelectedElement();
    if (curElement == null) {
        return;
    }
    dispose();
    editor.setHighlightRange(curElement.getLineStartPosition(), 1, true);
}
Also used : SpecfileElement(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement)

Example 3 with SpecfileElement

use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.

the class HeaderRecognitionTest method testGetComplexSectionName5.

@Test
public void testGetComplexSectionName5() {
    // FIXME: check for rest of line when -p is implemented
    // "blah bleh" should become the actual text of the section
    String testText = "%post -n name -p blah bleh";
    String[] tokens = testText.split("\\s+");
    SpecfileElement element;
    newFile(testText);
    element = parser.parseLine(testText, specfile, 0);
    assertEquals(SpecfileSection.class, element.getClass());
    SpecfileSection section = (SpecfileSection) element;
    assertEquals(tokens[0].substring(1), section.getName());
    assertEquals(tokens[2], section.getPackage().getPackageName());
}
Also used : SpecfileSection(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileSection) SpecfileElement(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement) Test(org.junit.Test)

Example 4 with SpecfileElement

use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.

the class HeaderRecognitionTest method testGetComplexSectionName1.

@Test
public void testGetComplexSectionName1() {
    String testText = "%post";
    SpecfileElement element;
    newFile(testText);
    element = parser.parseLine(testText, specfile, 0);
    assertEquals(SpecfileSection.class, element.getClass());
    SpecfileSection section = (SpecfileSection) element;
    assertEquals(testText.substring(1), section.getName());
    assertNull(section.getPackage());
}
Also used : SpecfileSection(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileSection) SpecfileElement(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement) Test(org.junit.Test)

Example 5 with SpecfileElement

use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.

the class HeaderRecognitionTest method testGetComplexSectionName3.

@Test
public void testGetComplexSectionName3() {
    String testText = "%post -n name";
    String[] tokens = testText.split("\\s+");
    SpecfileElement element;
    newFile(testText);
    element = parser.parseLine(testText, specfile, 0);
    assertEquals(SpecfileSection.class, element.getClass());
    SpecfileSection section = (SpecfileSection) element;
    assertEquals(tokens[0].substring(1), section.getName());
    assertEquals(tokens[2], section.getPackage().getPackageName());
}
Also used : SpecfileSection(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileSection) SpecfileElement(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement) Test(org.junit.Test)

Aggregations

SpecfileElement (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement)11 Test (org.junit.Test)7 SpecfileSection (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileSection)6 HashSet (java.util.HashSet)1 Position (org.eclipse.jface.text.Position)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SpecfilePreamble (org.eclipse.linuxtools.internal.rpm.ui.editor.parser.SpecfilePreamble)1 Specfile (org.eclipse.linuxtools.rpm.ui.editor.parser.Specfile)1 SpecfilePackage (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackage)1 SpecfilePackageContainer (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackageContainer)1