1 | /*
|
---|
2 | * 11/07/2004
|
---|
3 | *
|
---|
4 | * AbstractTokenMaker.java - An abstract implementation of TokenMaker.
|
---|
5 | *
|
---|
6 | * This library is distributed under a modified BSD license. See the included
|
---|
7 | * RSyntaxTextArea.License.txt file for details.
|
---|
8 | */
|
---|
9 | package org.fife.ui.rsyntaxtextarea;
|
---|
10 |
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * An abstract implementation of the
|
---|
14 | * {@link org.fife.ui.rsyntaxtextarea.TokenMaker} interface. It should
|
---|
15 | * be overridden for every language for which you want to provide
|
---|
16 | * syntax highlighting.<p>
|
---|
17 | *
|
---|
18 | * @see Token
|
---|
19 | *
|
---|
20 | * @author Robert Futrell
|
---|
21 | * @version 0.2
|
---|
22 | */
|
---|
23 | public abstract class AbstractTokenMaker extends TokenMakerBase {
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Hash table of words to highlight and what token type they are.
|
---|
27 | * The keys are the words to highlight, and their values are the
|
---|
28 | * token types, for example, <code>Token.RESERVED_WORD</code> or
|
---|
29 | * <code>Token.FUNCTION</code>.
|
---|
30 | */
|
---|
31 | protected TokenMap wordsToHighlight;
|
---|
32 |
|
---|
33 |
|
---|
34 | /**
|
---|
35 | * Constructor.
|
---|
36 | */
|
---|
37 | public AbstractTokenMaker() {
|
---|
38 | wordsToHighlight = getWordsToHighlight();
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Returns the words to highlight for this programming language.
|
---|
44 | *
|
---|
45 | * @return A <code>TokenMap</code> containing the words to highlight for
|
---|
46 | * this programming language.
|
---|
47 | */
|
---|
48 | public abstract TokenMap getWordsToHighlight();
|
---|
49 |
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * Removes the token last added from the linked list of tokens. The
|
---|
53 | * programmer should never have to call this directly; it can be called
|
---|
54 | * by subclasses of <code>TokenMaker</code> if necessary.
|
---|
55 | */
|
---|
56 | public void removeLastToken() {
|
---|
57 | if (previousToken==null) {
|
---|
58 | firstToken = currentToken = null;
|
---|
59 | }
|
---|
60 | else {
|
---|
61 | currentToken = previousToken;
|
---|
62 | currentToken.setNextToken(null);
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | } |
---|