Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-11-02 17:35:34 +0000
committeratikhomirov2006-11-02 17:35:34 +0000
commit56c861b4a279b3bac1c793aca863ba754ecc8f46 (patch)
treec493e1a020c798cea0522932b0c6893bb34f8738
parent0d0823451bca9fea936ffa6a2654638d977f77b3 (diff)
downloadorg.eclipse.gmf-tooling-56c861b4a279b3bac1c793aca863ba754ecc8f46.tar.gz
org.eclipse.gmf-tooling-56c861b4a279b3bac1c793aca863ba754ecc8f46.tar.xz
org.eclipse.gmf-tooling-56c861b4a279b3bac1c793aca863ba754ecc8f46.zip
refactor
-rw-r--r--plugins/org.eclipse.gmf.xpand.editor/src/org/eclipse/gmf/internal/xpand/editor/scan/XpandKeywordRule.java40
1 files changed, 12 insertions, 28 deletions
diff --git a/plugins/org.eclipse.gmf.xpand.editor/src/org/eclipse/gmf/internal/xpand/editor/scan/XpandKeywordRule.java b/plugins/org.eclipse.gmf.xpand.editor/src/org/eclipse/gmf/internal/xpand/editor/scan/XpandKeywordRule.java
index 9e0a5f3b8..89b2dd40b 100644
--- a/plugins/org.eclipse.gmf.xpand.editor/src/org/eclipse/gmf/internal/xpand/editor/scan/XpandKeywordRule.java
+++ b/plugins/org.eclipse.gmf.xpand.editor/src/org/eclipse/gmf/internal/xpand/editor/scan/XpandKeywordRule.java
@@ -14,9 +14,6 @@
*/
package org.eclipse.gmf.internal.xpand.editor.scan;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.jface.text.rules.ICharacterScanner;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.IToken;
@@ -27,18 +24,13 @@ import org.eclipse.jface.text.rules.Token;
*/
public class XpandKeywordRule implements IRule {
- private IToken token;
+ private final IToken token;
- private String[] keywords;
+ private final String[] keywords;
- private String[] getKeywords(final String prefix) {
- final List<String> result = new ArrayList<String>();
- for (final String w : keywords) {
- if (w.startsWith(prefix)) {
- result.add(w);
- }
- }
- return result.toArray(new String[result.size()]);
+ public XpandKeywordRule(final IToken token, final String[] keywords) {
+ this.token = token;
+ this.keywords = keywords;
}
private boolean isKeyword(final String word) {
@@ -51,25 +43,17 @@ public class XpandKeywordRule implements IRule {
return false;
}
- /**
- *
- */
- public XpandKeywordRule(final IToken token, final String[] keywords) {
- this.token = token;
- this.keywords = keywords;
- }
-
- /**
- * @param prefix
- * @return
- */
private boolean keywordExists(final String prefix) {
- final String[] currentWords = getKeywords(prefix.toString());
- return (currentWords != null) && (currentWords.length > 0);
+ for (final String w : keywords) {
+ if (w.startsWith(prefix)) {
+ return true;
+ }
+ }
+ return false;
}
public IToken evaluate(final ICharacterScanner scanner) {
- final StringBuffer buff = new StringBuffer();
+ final StringBuilder buff = new StringBuilder();
boolean stopReading = false;
int reads = 0;
while (!stopReading) {

Back to the top