aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-24 06:40:01 (EDT)
committersefftinge2009-04-24 06:40:01 (EDT)
commit11a6b2d5cf22ea539e515aba0dd0c565b63993e1 (patch)
tree6adb70f920e926f1578adc50d729729c35140932
parenta7bcd1547b24f3d97d777f66848424634bfbb951 (diff)
downloadorg.eclipse.xtext-11a6b2d5cf22ea539e515aba0dd0c565b63993e1.zip
org.eclipse.xtext-11a6b2d5cf22ea539e515aba0dd0c565b63993e1.tar.gz
org.eclipse.xtext-11a6b2d5cf22ea539e515aba0dd0c565b63993e1.tar.bz2
Feature: Provide sample implementation for CamelCase Completion
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/contentassist/PrefixMatcher.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/contentassist/PrefixMatcher.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/contentassist/PrefixMatcher.java
index a88154b..024fe51 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/contentassist/PrefixMatcher.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/contentassist/PrefixMatcher.java
@@ -7,13 +7,34 @@
*******************************************************************************/
package org.eclipse.xtext.ui.core.editor.contentassist;
+import org.eclipse.ui.dialogs.SearchPattern;
+
+import com.google.inject.ImplementedBy;
+
/**
* @author Sebastian Zarnekow - Initial contribution and API
*/
-public class PrefixMatcher {
+@ImplementedBy(PrefixMatcher.Simple.class)
+public abstract class PrefixMatcher {
+
+ public abstract boolean isCandidateMatchingPrefix(String name, String prefix);
- public boolean isCandidateMatchingPrefix(String name, String prefix) {
- return name.regionMatches(true, 0, prefix, 0,prefix.length());
+ public static class Simple extends PrefixMatcher {
+ @Override
+ public boolean isCandidateMatchingPrefix(String name, String prefix) {
+ return name.regionMatches(true, 0, prefix, 0, prefix.length());
+ }
}
-
+
+ public static class CamelCase extends PrefixMatcher {
+ @Override
+ public boolean isCandidateMatchingPrefix(String name, String prefix) {
+ SearchPattern pattern = new SearchPattern(
+ SearchPattern.RULE_BLANK_MATCH | SearchPattern.RULE_CAMELCASE_MATCH | SearchPattern.RULE_PREFIX_MATCH);
+ pattern.setPattern(prefix);
+ boolean result = pattern.matches(name);
+ return result;
+ }
+ }
+
}