|
Lines 18-29
Link Here
|
| 18 |
import org.eclipse.edt.ide.core.internal.errors.TokenStream; |
18 |
import org.eclipse.edt.ide.core.internal.errors.TokenStream; |
| 19 |
import org.eclipse.edt.ide.ui.EDTUIPlugin; |
19 |
import org.eclipse.edt.ide.ui.EDTUIPlugin; |
| 20 |
import org.eclipse.edt.ide.ui.internal.PluginImages; |
20 |
import org.eclipse.edt.ide.ui.internal.PluginImages; |
|
|
21 |
import org.eclipse.edt.ide.ui.internal.contentassist.proposalhandlers.EGLTemplateProposal; |
| 22 |
import org.eclipse.jface.text.BadLocationException; |
| 21 |
import org.eclipse.jface.text.IDocument; |
23 |
import org.eclipse.jface.text.IDocument; |
| 22 |
import org.eclipse.jface.text.IRegion; |
24 |
import org.eclipse.jface.text.IRegion; |
| 23 |
import org.eclipse.jface.text.ITextViewer; |
25 |
import org.eclipse.jface.text.ITextViewer; |
| 24 |
import org.eclipse.jface.text.Region; |
26 |
import org.eclipse.jface.text.Region; |
| 25 |
import org.eclipse.jface.text.templates.Template; |
27 |
import org.eclipse.jface.text.templates.Template; |
| 26 |
import org.eclipse.jface.text.templates.TemplateProposal; |
|
|
| 27 |
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; |
28 |
import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; |
| 28 |
import org.eclipse.swt.graphics.Point; |
29 |
import org.eclipse.swt.graphics.Point; |
| 29 |
|
30 |
|
|
Lines 52-63
Link Here
|
| 52 |
/** |
53 |
/** |
| 53 |
* Returns the array of matching templates. |
54 |
* Returns the array of matching templates. |
| 54 |
*/ |
55 |
*/ |
| 55 |
public TemplateProposal[] getResults() { |
56 |
public EGLTemplateProposal[] getResults() { |
| 56 |
return (TemplateProposal[]) fProposals.toArray(new TemplateProposal[fProposals.size()]); |
57 |
return (EGLTemplateProposal[]) fProposals.toArray(new EGLTemplateProposal[fProposals.size()]); |
| 57 |
} |
58 |
} |
| 58 |
|
59 |
|
| 59 |
public void complete(TokenStream tokenStream, ITextViewer viewer, int completionPosition, ParseStack parseStack, String prefix) { |
60 |
public void complete(TokenStream tokenStream, ITextViewer viewer, int completionPosition, ParseStack parseStack, String prefix) { |
| 60 |
IDocument document = viewer.getDocument(); |
61 |
IDocument document = viewer.getDocument(); |
|
|
62 |
String lineDelimiter = "\n"; |
| 63 |
try { |
| 64 |
lineDelimiter =document.getLineDelimiter(0); |
| 65 |
} catch (BadLocationException e) { |
| 66 |
} |
| 67 |
|
| 61 |
Point selection = viewer.getSelectedRange(); |
68 |
Point selection = viewer.getSelectedRange(); |
| 62 |
EGLTemplateContext context = fContextType.createContext(document, completionPosition - prefix.length(), selection.y + prefix.length(), parseStack, prefix); |
69 |
EGLTemplateContext context = fContextType.createContext(document, completionPosition - prefix.length(), selection.y + prefix.length(), parseStack, prefix); |
| 63 |
int start = context.getStart(); |
70 |
int start = context.getStart(); |
|
Lines 68-78
Link Here
|
| 68 |
// If the template matches the prefix, then set up the necessary info and add to list of completions. |
75 |
// If the template matches the prefix, then set up the necessary info and add to list of completions. |
| 69 |
if (context.canEvaluate(templates[i])) { |
76 |
if (context.canEvaluate(templates[i])) { |
| 70 |
fProposals.add( |
77 |
fProposals.add( |
| 71 |
new TemplateProposal( |
78 |
new EGLTemplateProposal( |
| 72 |
templates[i], |
79 |
templates[i], |
| 73 |
context, |
80 |
context, |
| 74 |
region, |
81 |
region, |
| 75 |
PluginImages.get(PluginImages.IMG_OBJS_TEMPLATE))); |
82 |
PluginImages.get(PluginImages.IMG_OBJS_TEMPLATE),lineDelimiter)); |
| 76 |
} |
83 |
} |
| 77 |
} |
84 |
} |
| 78 |
} |
85 |
} |