Search in sources :

Example 1 with SpecfileCompletionProcessor

use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor 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;
    }
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) SpecfileEditor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor) SpecfileCompletionProcessor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor) Test(org.junit.Test)

Example 2 with SpecfileCompletionProcessor

use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor 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);
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) SpecfileEditor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor) SpecfileCompletionProcessor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor)

Example 3 with SpecfileCompletionProcessor

use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor 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);
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) SpecfileEditor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor) SpecfileCompletionProcessor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor) Test(org.junit.Test)

Example 4 with SpecfileCompletionProcessor

use of org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor 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);
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) SpecfileEditor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor) SpecfileCompletionProcessor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor) Test(org.junit.Test)

Aggregations

ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)4 SpecfileCompletionProcessor (org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor)4 SpecfileEditor (org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor)4 Test (org.junit.Test)3