Search in sources :

Example 1 with SpecfileEditor

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;
    }
}
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 SpecfileEditor

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);
}
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 SpecfileEditor

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);
}
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 SpecfileEditor

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);
}
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 5 with SpecfileEditor

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));
    }
}
Also used : SpecfileConfiguration(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileConfiguration) SourceViewer(org.eclipse.jface.text.source.SourceViewer) SpecfileEditor(org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor)

Aggregations

SpecfileEditor (org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileEditor)11 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)4 SpecfileCompletionProcessor (org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileCompletionProcessor)4 Test (org.junit.Test)3 BadLocationException (org.eclipse.jface.text.BadLocationException)2 IDocument (org.eclipse.jface.text.IDocument)2 SpecfileParser (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileParser)2 StringTokenizer (com.ibm.icu.util.StringTokenizer)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 IFile (org.eclipse.core.resources.IFile)1 BadPositionCategoryException (org.eclipse.jface.text.BadPositionCategoryException)1 IRegion (org.eclipse.jface.text.IRegion)1 ITypedRegion (org.eclipse.jface.text.ITypedRegion)1 Position (org.eclipse.jface.text.Position)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1 URLHyperlink (org.eclipse.jface.text.hyperlink.URLHyperlink)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1 SpecfileConfiguration (org.eclipse.linuxtools.internal.rpm.ui.editor.SpecfileConfiguration)1 SpecfileSource (org.eclipse.linuxtools.internal.rpm.ui.editor.parser.SpecfileSource)1