use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.
the class HeaderRecognitionTest method testGetComplexSectionName4.
@Test
public void testGetComplexSectionName4() {
// FIXME: check for rest of line when -p is implemented
// this should be an error case
String testText = "%post -n name -p";
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());
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.
the class HeaderRecognitionTest method testGetComplexSectionName6.
@Test
public void testGetComplexSectionName6() {
String testText = "%post -p blah bleh";
// FIXME: check for rest of line when -p is implemented
// "blah bleh" should become the actual text of the section
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());
assertNull(section.getPackage());
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.
the class HeaderRecognitionTest method testGetSimpleSectionName.
@Test
public void testGetSimpleSectionName() {
String testText = "%prep";
SpecfileElement element;
newFile(testText);
element = parser.parseLine(testText, specfile, 0);
assertEquals(SpecfileSection.class, element.getClass());
assertEquals(testText.substring(1), ((SpecfileSection) element).getName());
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.
the class PatchApplicationTest method testParsePatchApplication.
@Test
public void testParsePatchApplication() {
String specText = "Patch3: somefilesomewhere.patch\n%patch3";
String testText = "%patch3";
newFile(specText);
SpecfileElement element = parser.parseLine(testText, specfile, 1);
assertEquals(SpecfilePatchMacro.class, element.getClass());
assertEquals(3, ((SpecfilePatchMacro) element).getPatchNumber());
}
use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.
the class SpecfileFoldingStructureProvider method addFoldingRegions.
private Set<Position> addFoldingRegions(List<SpecfileElement> elements) {
Set<Position> regions = new HashSet<>();
// add folding on the preamble section
Position position;
if (elements.size() > 0) {
SpecfileElement element = elements.get(0);
position = new Position(0, element.getLineStartPosition() - 1);
regions.add(position);
}
for (int i = 0; i < elements.size(); i++) {
SpecfileElement startElement = elements.get(i);
int offsetPos = startElement.getLineStartPosition();
int lenghtPos;
if (i < elements.size() - 1) {
SpecfileElement endElement = elements.get(i + 1);
lenghtPos = endElement.getLineStartPosition() - startElement.getLineStartPosition() - 1;
} else {
lenghtPos = sDocument.getLength() - startElement.getLineStartPosition();
}
position = new Position(offsetPos, lenghtPos);
regions.add(position);
}
return regions;
}
Aggregations