void AddTemplates(TextArea textArea, char charTyped) { if (!ShowTemplates) return; ICompletionData suggestedData = DefaultIndex >= 0 ? completionData[DefaultIndex] : null; ICompletionData[] templateCompletionData = new TemplateCompletionDataProvider().GenerateCompletionData(fileName, textArea, charTyped); if (templateCompletionData == null || templateCompletionData.Length == 0) return; for (int i = 0; i < completionData.Count; i++) { if (completionData[i].ImageIndex == ClassBrowserIconService.KeywordIndex) { string text = completionData[i].Text; for (int j = 0; j < templateCompletionData.Length; j++) { if (templateCompletionData[j] != null && templateCompletionData[j].Text == text) { // replace keyword with template completionData[i] = templateCompletionData[j]; templateCompletionData[j] = null; } } } } // add non-keyword code templates for (int j = 0; j < templateCompletionData.Length; j++) { if (templateCompletionData[j] != null) completionData.Add(templateCompletionData[j]); } if (suggestedData != null) { completionData.Sort(DefaultCompletionData.Compare); DefaultIndex = completionData.IndexOf(suggestedData); } }
void AddTemplates(TextArea textArea, char charTyped) { if (!ShowTemplates) { return; } ICompletionData suggestedData = DefaultIndex >= 0 ? completionData[DefaultIndex] : null; ICompletionData[] templateCompletionData = new TemplateCompletionDataProvider().GenerateCompletionData(fileName, textArea, charTyped); if (templateCompletionData == null || templateCompletionData.Length == 0) { return; } for (int i = 0; i < completionData.Count; i++) { if (completionData[i].ImageIndex == ClassBrowserIconService.KeywordIndex) { string text = completionData[i].Text; for (int j = 0; j < templateCompletionData.Length; j++) { if (templateCompletionData[j] != null && templateCompletionData[j].Text == text) { // replace keyword with template completionData[i] = templateCompletionData[j]; templateCompletionData[j] = null; } } } } // add non-keyword code templates for (int j = 0; j < templateCompletionData.Length; j++) { if (templateCompletionData[j] != null) { completionData.Add(templateCompletionData[j]); } } if (suggestedData != null) { completionData.Sort(DefaultCompletionData.Compare); DefaultIndex = completionData.IndexOf(suggestedData); } }