Search in sources :

Example 1 with WordMatch

use of org.netbeans.editor.WordMatch in project enclojure by EricThorsen.

the class ClojureCodeCompletion_Provider method getAllHippieMatches.

public static ArrayList<String> getAllHippieMatches(JTextComponent target) {
    ArrayList<String> ret = new ArrayList<String>();
    EditorUI editorUI = Utilities.getEditorUI(target);
    Caret caret = target.getCaret();
    int dotPos = caret.getDot();
    WordMatch m = editorUI.getWordMatch();
    if (m != null) {
        String s = null;
        String searchWord = "";
        int c = 0;
        do {
            c += 1;
            s = m.getMatchWord(dotPos, false);
            if (s != null && !ret.contains(s)) {
                ret.add(s);
                if (c == 1)
                    searchWord = m.getPreviousWord();
            }
        } while (s != null && m.isFound());
        if (searchWord == null)
            searchWord = "";
        do {
            s = m.getMatchWord(dotPos + searchWord.length() + 2, true);
            if (s != null && !ret.contains(s))
                if (!s.equalsIgnoreCase(searchWord) && !ret.contains(s))
                    ret.add(s);
        } while (s != null && m.isFound());
    }
    return ret;
}
Also used : WordMatch(org.netbeans.editor.WordMatch) EditorUI(org.netbeans.editor.EditorUI) ArrayList(java.util.ArrayList) Caret(javax.swing.text.Caret)

Aggregations

ArrayList (java.util.ArrayList)1 Caret (javax.swing.text.Caret)1 EditorUI (org.netbeans.editor.EditorUI)1 WordMatch (org.netbeans.editor.WordMatch)1