Package org.jnode.shell

Examples of org.jnode.shell.CommandCompletions


            if (url.getProtocol().equals("file") &&
                    (url.getAuthority() == null || url.getAuthority().length() == 0) &&
                    (url.getQuery() == null || url.getQuery().length() == 0)) {
                // Use a FileArgument to do the work of completing the pathname,
                // capturing the results using our own CompletionInfo object.
                CompletionInfo myCompletion = new CommandCompletions();
                new FileArgument(null, getFlags()).complete(myCompletion, url.getPath(), flags);
                // Then turn the completions back into "file:" URLs
                for (String c : myCompletion.getCompletions()) {
                    // (Kludge - the 'true' argument prevents an extra space
                    // character from being appended to the completions.)
                    completions.addCompletion("file:" + c, true);
                }
            }
View Full Code Here


*/
public class CompletionInfoTest {

    @Test
    public void testConstructor() {
        new CommandCompletions();
    }
View Full Code Here

        new CommandCompletions();
    }

    @Test
    public void testAddCompletion() {
        CompletionInfo ci = new CommandCompletions();

        ci.addCompletion("full-1");
        ci.addCompletion("full-2", false);
        ci.addCompletion("partial", true);
        SortedSet<String> completions = ci.getCompletions();
        Assert.assertEquals(3, completions.size());

        Iterator<String> it = completions.iterator();
        Assert.assertEquals("full-1 ", it.next());
        Assert.assertEquals("full-2 ", it.next());
View Full Code Here

        Assert.assertEquals("partial", it.next());
    }

    @Test
    public void testSetCompletionStart() {
        CompletionInfo ci = new CommandCompletions();
        Assert.assertEquals(-1, ci.getCompletionStart());
        ci.setCompletionStart(-1);
        Assert.assertEquals(-1, ci.getCompletionStart());
        ci.setCompletionStart(1);
        Assert.assertEquals(1, ci.getCompletionStart());
        ci.setCompletionStart(1);
        Assert.assertEquals(1, ci.getCompletionStart());
        try {
            ci.setCompletionStart(2);
            Assert.fail("no exception");
        } catch (IllegalArgumentException ex) {
            // expected
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testGetCompletion() {
        CompletionInfo ci = new CommandCompletions();
        Assert.assertEquals(null, ci.getCompletion());

        ci.addCompletion("full-1");
        Assert.assertEquals("full-1 ", ci.getCompletion());

        ci.addCompletion("full-2");
        Assert.assertEquals("full-", ci.getCompletion());

        ci.addCompletion("partial", true);
        Assert.assertEquals(null, ci.getCompletion());
    }
View Full Code Here

                    wordStart = j + 1;
                }
            }
            String lastWord = partial.substring(wordStart);
            Completable completable = interpreter.parsePartial(shell, partial);
            CommandCompletions completions = new CommandCompletions();
            completable.complete(completions, shell);
            Set<String> completionWords = completions.getCompletions();
            switch (flags.charAt(inWord)) {
                case 'T':
                    // Expect completions
                    Assert.assertTrue("got no completions: " + diag(partial, completions),
                            completionWords.size() > 0);
View Full Code Here

TOP

Related Classes of org.jnode.shell.CommandCompletions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.