1 package org.simantics.scl.compiler.completions;
3 public class PrefixUtil {
4 public static String findPrefix(String sourceText, int end) {
6 for(position=end-1;position >= 0 && isPrefixChar(sourceText.charAt(position));--position);
8 while(position < end && !isPrefixStart(sourceText.charAt(position)))
10 return sourceText.substring(position, end);
13 private static boolean isPrefixStart(char c) {
14 return Character.isJavaIdentifierStart(c);
17 private static boolean isPrefixChar(char c) {
18 return Character.isJavaIdentifierPart(c) || c=='.';
21 public static String[] splitPrefix(String prefix) {
23 for(int i=0;i<prefix.length();++i)
24 if(prefix.charAt(i) == '.')
26 String[] result = new String[partCount];
29 for(int i=0;i<prefix.length();++i)
30 if(prefix.charAt(i) == '.') {
31 result[partId++] = prefix.substring(begin, i);
34 result[partId] = prefix.substring(begin);