use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor in project linuxtools by eclipse.
the class SpecfileCompletionProcessorTest method testBRCompletionOrder.
@Test
public void testBRCompletionOrder() throws Exception {
setPackageList(new String[] { "package3", "package2", "package4", "package1" });
SpecfileEditor editor = initEditor(BUILD_REQUIRES);
testProject.refresh();
editor.doRevertToSaved();
editor.getSpecfileSourceViewer().setSelectedRange(BUILD_REQUIRES.length(), 0);
SpecfileCompletionProcessor processor = new SpecfileCompletionProcessor();
ICompletionProposal[] proposals = processor.computeCompletionProposals(editor.getSpecfileSourceViewer(), BUILD_REQUIRES.length());
assertTrue("Cannot perform test; not enough proposals", proposals.length > 1);
ICompletionProposal previous = proposals[0];
for (int i = 1; i < proposals.length; i++) {
ICompletionProposal current = proposals[i];
assertTrue("Proposals are not in alphabetical order", previous.getDisplayString().compareToIgnoreCase(current.getDisplayString()) < 0);
previous = current;
}
}
use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor in project linuxtools by eclipse.
the class SpecfileCompletionProcessorTest method computeCompletionProposals.
private synchronized void computeCompletionProposals(String specContent, int occurances) throws Exception {
SpecfileEditor editor = initEditor(specContent);
testProject.refresh();
// This is needed so the changes in the testFile are loaded in the
// editor
editor.doRevertToSaved();
SpecfileCompletionProcessor complProcessor = new SpecfileCompletionProcessor();
assertNotNull(complProcessor);
editor.getSpecfileSourceViewer().setSelectedRange(0, 0);
ICompletionProposal[] proposals = complProcessor.computeCompletionProposals(editor.getSpecfileSourceViewer(), 0);
int sourceComplCount = 0;
for (ICompletionProposal proposal : proposals) {
if (proposal.getDisplayString().startsWith("%{SOURCE")) {
++sourceComplCount;
}
}
assertEquals(occurances, sourceComplCount);
}
use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor in project linuxtools by eclipse.
the class SpecfileCompletionProcessorTest method testBRCompletionNonAlphaDot.
@Test
public void testBRCompletionNonAlphaDot() throws Exception {
setPackageList(new String[] { "java-1.5.0-gcj", "java-1.7.0-openjdk", "java-1.7.0-openjdk-devel", "java-1.7.0-openjdk-javadoc" });
SpecfileEditor editor = initEditor(NON_ALPHA_DOT);
testProject.refresh();
// This is needed so the changes in the testFile are loaded in the
// editor
editor.doRevertToSaved();
SpecfileCompletionProcessor complProcessor = new SpecfileCompletionProcessor();
assertNotNull(complProcessor);
editor.getSpecfileSourceViewer().setSelectedRange(NON_ALPHA_DOT.length(), 0);
ICompletionProposal[] proposals = complProcessor.computeCompletionProposals(editor.getSpecfileSourceViewer(), NON_ALPHA_DOT.length());
int sourceComplCount = 0;
for (ICompletionProposal proposal : proposals) {
if (proposal.getDisplayString().startsWith("java-1.")) {
++sourceComplCount;
}
}
assertEquals(4, sourceComplCount);
}
use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor in project linuxtools by eclipse.
the class SpecfileCompletionProcessorTest method testBRCompletionNonAlphaPlus.
@Test
public void testBRCompletionNonAlphaPlus() throws Exception {
setPackageList(new String[] { "libstdc++", "libstdc++-devel" });
SpecfileEditor editor = initEditor(NON_ALPHA_PLUS);
testProject.refresh();
// This is needed so the changes in the testFile are loaded in the
// editor
editor.doRevertToSaved();
SpecfileCompletionProcessor complProcessor = new SpecfileCompletionProcessor();
assertNotNull(complProcessor);
editor.getSpecfileSourceViewer().setSelectedRange(NON_ALPHA_PLUS.length(), 0);
ICompletionProposal[] proposals = complProcessor.computeCompletionProposals(editor.getSpecfileSourceViewer(), NON_ALPHA_PLUS.length());
int sourceComplCount = 0;
for (ICompletionProposal proposal : proposals) {
if (proposal.getDisplayString().startsWith("libstdc+")) {
++sourceComplCount;
}
}
assertEquals(2, sourceComplCount);
}
use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor in project linuxtools by eclipse.
the class SpecMergeViewer method configureTextViewer.
@Override
protected void configureTextViewer(TextViewer textViewer) {
if (textViewer instanceof SourceViewer) {
SpecfileEditor editor = new SpecfileEditor();
((SourceViewer) textViewer).configure(new SpecfileConfiguration(editor));
}
}
Aggregations