private char[] allowedCharacters = {\r
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','å','ä','ö',\r
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Å','Ä','Ö',\r
- '1','2','3','4','5','6','7','8','9','0','.',\r
- '(',')'};\r
+ '1','2','3','4','5','6','7','8','9','0','.','_','(',')'};\r
\r
+ private String allowedConnectedCharactersRegExp = "[\\Q({[:;,<=>+-*/^\\E]";\r
+ \r
public CompletionProcessor(Table allowedVariables, boolean allowFunctions){\r
this.allowedVariables = allowedVariables;\r
\r
e.printStackTrace();\r
}\r
}\r
- Collections.sort(functions);\r
+ Collections.sort(functions);\r
+ for (int i = 0; i < functions.size(); ++i) {\r
+ functions.set(i, functions.get(i) + "()");\r
+ }\r
}\r
\r
private ICompletionProposal[] collectProposals(String token, int offset) {\r
}\r
\r
ArrayList<ICompletionProposal> resultArray = new ArrayList<ICompletionProposal>();\r
- for (String function : functions) {\r
- if (token.length() == 0 || function.toUpperCase().startsWith(token.toUpperCase())) {\r
- resultArray.add(new CompletionProposal(function, \r
- offset - token.length(),\r
- token.length(), \r
- function.length()));\r
- } \r
- }\r
for (String variable : variables) {\r
if (token.length() == 0 || variable.toUpperCase().startsWith(token.toUpperCase())) {\r
resultArray.add(new CompletionProposal(variable, \r
variable.length()));\r
} \r
}\r
+ for (String function : functions) {\r
+ if (token.length() == 0 || function.toUpperCase().startsWith(token.toUpperCase())) {\r
+ resultArray.add(new CompletionProposal(function, \r
+ offset - token.length(),\r
+ token.length(), \r
+ function.length() - 1));\r
+ } \r
+ }\r
ICompletionProposal[] result = new ICompletionProposal[resultArray.size()];\r
for (int i = 0; i < result.length; ++i) {\r
result[i] = resultArray.get(i);\r
public ICompletionProposal[] computeCompletionProposals(\r
ITextViewer viewer, int offset) {\r
String equation = viewer.getDocument().get();\r
-// System.out.println(equation + "\noffset = " + offset);\r
\r
if (equation.length() == 0 \r
|| offset == 0\r
}\r
\r
equation = equation.substring(0, offset);\r
-// System.out.println(equation + "\noffset = " + offset);\r
\r
// Split into tokens on whitespace characters\r
- String[] tokens = equation.split("\\s+");\r
+ String[] tokens = equation.split("[\\s]");\r
if (tokens.length == 0) {\r
return collectProposals("", offset);\r
}\r
String token = tokens[tokens.length - 1];\r
+ \r
+ // Split the last token on '+', '-', etc. characters \r
+ String tokensOfLastToken[] = token.split(allowedConnectedCharactersRegExp);\r
+ if (tokensOfLastToken.length == 0) {\r
+ return collectProposals("", offset);\r
+ }\r
+ token = tokensOfLastToken[tokensOfLastToken.length - 1];\r
// System.out.println(token + "\noffset = " + offset);\r
\r
return collectProposals(token, offset);\r
private char[] alphaNumericCharacters = {\r
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','å','ä','ö',\r
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Å','Ä','Ö',\r
- '1','2','3','4','5','6','7','8','9','0','.'};\r
+ '1','2','3','4','5','6','7','8','9','0','.','_'};\r
\r
/**\r
* Create a new RVIModifier and attach a content proposal support to control\r