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