Show More
@@ -36,29 +36,40 b'' | |||
|
36 | 36 | } |
|
37 | 37 | |
|
38 | 38 | // find all 'words' of current cell |
|
39 |
|
|
|
39 | var getAllTokens = function(editor) | |
|
40 | 40 | { |
|
41 | 41 | var found = []; |
|
42 | // get all text remove and split it before dot and at space | |
|
43 | // keep the dot for completing token that also start with dot | |
|
44 | var candidates = editor.getValue() | |
|
45 | .replace(/[.]/g," .") | |
|
46 | .replace(/[ ]/g,"\n") | |
|
47 | .split('\n'); | |
|
48 | // append to arry if not already (the function) | |
|
42 | ||
|
43 | // add to found if not already in it | |
|
49 | 44 | function maybeAdd(str) { |
|
50 | 45 | if (!arrayContains(found, str)) found.push(str); |
|
51 | 46 | } |
|
52 | // append to arry if not already | |
|
53 | // (here we do it ) | |
|
54 | for( var c in candidates ) | |
|
47 | ||
|
48 | // loop through all token on all lines | |
|
49 | var lineCount = editor.lineCount(); | |
|
50 | // loop on line | |
|
51 | for( var l=0; l< lineCount ; l++) | |
|
55 | 52 | { |
|
56 | if(candidates[c].length >= 1){ | |
|
57 | maybeAdd(candidates[c]);} | |
|
53 | var line = editor.getLine(l); | |
|
54 | //loop on char | |
|
55 | for( var c = 1 ; c < line.length ; c++) | |
|
56 | { | |
|
57 | var tk = editor.getTokenAt({line:l,ch:c}); | |
|
58 | // if token has a class, it has geat chances of beeing | |
|
59 | // of interest. Add it to the list of possible completions. | |
|
60 | // we could skip token of ClassName 'comment' | |
|
61 | // or 'number' and 'operator' | |
|
62 | if(tk.className != null){ | |
|
63 | maybeAdd(tk.string); | |
|
64 | } | |
|
65 | // jump to char after end of current token | |
|
66 | c = tk.end; | |
|
67 | } | |
|
58 | 68 | } |
|
59 | 69 | return found; |
|
60 | 70 | } |
|
61 | 71 | |
|
72 | ||
|
62 | 73 | function getCompletions(token,editor) |
|
63 | 74 | { |
|
64 | 75 | var candidates = getAllTokens(editor); |
General Comments 0
You need to be logged in to leave comments.
Login now