/// <summary> /// Invokes <see cref="AddSuggestionsForConstantKeywords"/> to supply suggestions for constant /// keywords. May be overridden to supply additional suggestions or to change the set of acceptable /// keywords. /// </summary> public virtual void AddSuggestionsForConstantKeywords() => IntellisenseHelper.AddSuggestionsForMatches( this, TexlLexer.LocalizedInstance.GetConstantKeywords(false), SuggestionKind.KeyWord, SuggestionIconKind.Other, requiresSuggestionEscaping: false);
private void Button_Select_Click(object sender, RoutedEventArgs e) { if (ComboBox_Settings.SelectedItem != null) { var name = ComboBox_Settings.SelectedItem.ToString(); if (BabePackage.Setting.ContainsSetting(name) && BabePackage.Setting.CurrentSetting != name) { if (!Directory.Exists(BabePackage.Setting.GetSetting(name).Folder)) { System.Windows.MessageBox.Show("Script folder not exist, please check it.", "Error"); return; } BabePackage.Setting.CurrentSetting = name; TextBlock_Select.Text = BabePackage.Setting.CurrentSetting; BabePackage.Setting.Save(); IntellisenseHelper.Scan(); BabePackage.WindowManager.ShowFolderWindow(); BabePackage.WindowManager.UpdateUI(); Button_Select.IsEnabled = false; Babe.Lua.LuaProject.CloseAllTempLuaProject(); } } }
public bool FillWord(String word, List <Completion> completions) { int count = completions.Count; //提示全局索引 var list = IntellisenseHelper.GetGlobal(); //提示当前文件单词 var tokens = IntellisenseHelper.GetFileTokens(); list = list.Concat(tokens).Distinct(); foreach (LuaMember s in list) { completions.Add(new LuaCompletion( show: s.Name, completion: s is LuaFunction ? s.ToString() : s.Name, description: string.Format("{0} {1}{2}", s.ToString(), GetMemberPath(s), s.Comment), //description : s.GetType().Name + " : " + s.ToString() + " in file: " + s.File + s.Comment, icon: _provider.GetImageSource(s.GetType()) )); } #if DEBUG System.Diagnostics.Debug.Print("fill items:" + (completions.Count - count)); #endif return(completions.Count > count); }
void TextViewCreationListener_FileContentChanged(object sender, FileContentChangedEventArgs e) { if (e.Tree.Root == null) { return; } IntellisenseHelper.Refresh(e.Tree); }
public bool FillWord(String word, List <Completion> completions) { int count = completions.Count; //提示全局索引 var list = IntellisenseHelper.GetGlobal(); //提示当前文件单词 var tokens = IntellisenseHelper.GetFileTokens(); list = list.Concat(tokens).Distinct(); foreach (LuaMember s in list) { completions.Add(new Completion(s.Name, s.Name, s.GetType().Name + ":" + s.ToString(), null, "icon")); } return(completions.Count > count); }
public bool FillTable(String word, char dot, List <Completion> completions) { var count = completions.Count; var table = IntellisenseHelper.GetTable(word); if (table != null) { var result = table.GetFullMembers(); if (dot == '.') { foreach (var list in result) { foreach (LuaMember l in list.Value) { completions.Add(new Completion(l.Name, l.Name, list.Key + dot + l.ToString(), null, "icon")); } } } else { foreach (var list in result) { foreach (LuaMember l in list.Value) { if (l is LuaFunction) { completions.Add(new Completion(l.Name, l.Name, list.Key + dot + l.ToString(), null, "icon")); } } } } } //else //找不到table。拿文件单词进行提示。 //{ // var tokens = IntellisenseHelper.GetFileTokens(); // foreach (LuaMember lm in tokens) // { // completions.Add(new Completion(lm.Name, lm.Name, lm.Name, null, "icon")); // } //} return(completions.Count > count); }
private void Button_Delete_Click(object sender, RoutedEventArgs e) { if (ComboBox_Settings.SelectedItem == null) { return; } var name = ComboBox_Settings.SelectedItem.ToString(); string strDeleteConfirm = string.Format("Sure delete {0}?", name); if (System.Windows.MessageBox.Show(strDeleteConfirm, "delete", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } if (name == BabePackage.Setting.CurrentSetting) { BabePackage.Setting.CurrentSetting = string.Empty; IntellisenseHelper.Scan(); DTEHelper.Current.UpdateUI(); } BabePackage.Setting.RemoveSetting(name); BabePackage.Setting.Save(); //ComboBox_Settings.Items.Remove(name); InitComboBox(); //删除后如果当前选择项为空则默认选中一选项,否则选中当前项 if (string.IsNullOrWhiteSpace(BabePackage.Setting.CurrentSetting)) { ComboBox_Settings.SelectedItem = BabePackage.Setting.GetFirstSettingName(); } else { ComboBox_Settings.SelectedItem = BabePackage.Setting.CurrentSetting; } TextBlock_Select.Text = BabePackage.Setting.CurrentSetting; Button_Save.IsEnabled = true; }
void dteEvents_OnStartupComplete() { if (BabePackage.Setting.IsFirstInstall) { BabePackage.WindowManager.ShowSettingWindow(); //BabePackage.Current.ShowFolderWindow(null, null); //BabePackage.Current.ShowOutlineWindow(null, null); //var props = DTE.Properties["TextEditor", "Lua"]; //props.Item("IndentStyle").Value = EnvDTE.vsIndentStyle.vsIndentStyleDefault; } else if (!string.IsNullOrWhiteSpace(BabePackage.Setting.CurrentSetting)) { IntellisenseHelper.Scan(); } if (BabePackage.Setting.HideUselessViews) { HiddenVSWindows(); } //打开上次关闭时打开的文件 //启动完成。开始初始化。 //如果是此版本第一次运行,更改缩进设置项为“块” if (Properties.Settings.Default.IsFirstRun) { IVsTextManager textMgr = (IVsTextManager)BabePackage.Current.GetService(typeof(SVsTextManager)); var langPrefs = new LANGPREFERENCES[1]; langPrefs[0].guidLang = typeof(LuaLanguageInfo).GUID; ErrorHandler.ThrowOnFailure(textMgr.GetUserPreferences(null, null, langPrefs, null)); langPrefs[0].IndentStyle = Microsoft.VisualStudio.TextManager.Interop.vsIndentStyle.vsIndentStyleDefault; textMgr.SetUserPreferences(null, null, langPrefs, null); Properties.Settings.Default.IsFirstRun = false; Properties.Settings.Default.Save(); } //注册编辑器内容变化通知 TextViewCreationListener.FileContentChanged += TextViewCreationListener_FileContentChanged; Logger.UploadLog(); Updater.CheckVersion(); }
void cmdEvents_BeforeVSExit(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { IntellisenseHelper.Stop(); //var Files = new System.Xml.Linq.XElement(BabePackage.Setting.OpenFiles.Name); //foreach (Document doc in DTE.Documents) //{ // if (doc != DTE.ActiveDocument) // { // var file = new System.Xml.Linq.XElement("File"); // file.Value = doc.FullName; // Files.Add(file); // } //} //if (DTE.ActiveDocument != null) //{ // var file = new System.Xml.Linq.XElement("Active"); // file.Value = DTE.ActiveDocument.FullName; //} }
void view_GotAggregateFocus(object sender, EventArgs e) { if (_cur != sender) { var file = BabePackage.DTEHelper.DTE.ActiveDocument.FullName; if (!System.IO.File.Exists(file)) { //文件已经被移除,我们关闭窗口 IntellisenseHelper.RemoveFile(file); BabePackage.DTEHelper.DTE.ActiveDocument.Close(EnvDTE.vsSaveChanges.vsSaveChangesNo); return; } System.Diagnostics.Debug.Print("document got focus"); _cur = sender as IWpfTextView; IntellisenseHelper.SetCurrentFile(file); BabePackage.DTEHelper.SetStatusBarText(EncodingDecide.DecideFileEncoding(BabePackage.DTEHelper.DTE.ActiveDocument.FullName).ToString()); } }
private void Button_Select_Click(object sender, RoutedEventArgs e) { if (ComboBox_Settings.SelectedItem != null) { var name = ComboBox_Settings.SelectedItem.ToString(); if (BabePackage.Setting.ContainsSetting(name) && BabePackage.Setting.CurrentSetting != name) { BabePackage.Setting.CurrentSetting = name; TextBlock_Select.Text = BabePackage.Setting.CurrentSetting; BabePackage.Setting.Save(); IntellisenseHelper.Scan(); BabePackage.Current.ShowFolderWindow(null, null); DTEHelper.Current.UpdateUI(); Button_Select.IsEnabled = false; } } }
void TextViewCreationListener_FileContentChanged(object sender, FileContentChangedEventArgs e) { IntellisenseHelper.Refresh(e.Tree); }
public override bool HasSuggestedActions(ITextView textView, ITextBuffer textBuffer, int caretPosition, ElementNode element, AttributeNode attribute, HtmlPositionType positionType) { return(this.IsTargetHtmlAttribute(element, attribute) && !IntellisenseHelper.IsKnownHtmlAttribute(attribute.Name)); }
public void EditorMouseHover(ICSharpCode.AvalonEdit.TextEditor editor, DepthScanner scanner, MouseEventArgs e) { TextViewPosition?pos = editor.GetPositionFromPoint(e.GetPosition(editor)); if (pos != null) { try { int line = pos.Value.Line; int offset = editor.Document.GetOffset(pos.Value.Location); Globals globs = GetGlobals(); if (globs != null) { bool isFunc = false; string[] words = IntellisenseHelper.ExtractPath(editor.Document, offset, pos.Value.Location.Line, out isFunc); if (words != null && words.Length > 0) { BaseTypeInfo info = null; FunctionInfo func = null; NameResolver reso = new NameResolver(globs, scanner); if (words.Length > 1) { for (int i = 0; i < words.Length; ++i) { if (i == words.Length - 1 && info != null && isFunc) { if (info is TypeInfo) { func = ((TypeInfo)info).Functions.FirstOrDefault(f => f.Name.Equals(words[i])); } } else { if (info == null) { info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, words[i]); } else if (info != null && info is TypeInfo) { if (((TypeInfo)info).Properties.ContainsKey(words[i])) { info = ((TypeInfo)info).Properties[words[i]]; } } } } } else if (isFunc && words.Length == 1) { func = globs.GetFunction(words[0]); } else if (!isFunc && words.Length == 1) { info = reso.GetClassType(editor.Document, line, words[0]); if (info == null) { TypeInfo ty = globs.GetTypeInfo(words[0]); if (ty != null) { info = ty; } } } string msg = ""; // Ask documentation for the information if (info != null && func != null && info is TypeInfo) { //member function msg = func.ReturnType.Name + " " + func.Name; string m = IDEProject.inst().DocDatabase.GetDocumentationFor(((TypeInfo)info).Name + "::" + func.Name + func.Inner); if (m != null) { msg += "\r\n" + m; } } else if (func != null) { //global function msg = func.ReturnType.Name + " " + func.Name; string m = IDEProject.inst().DocDatabase.GetDocumentationFor(func.Name + func.Inner); if (m != null) { msg += "\r\n" + m; } } else if (info != null && info is TypeInfo) { //global or member type msg = ((TypeInfo)info).Name; string m = IDEProject.inst().DocDatabase.GetDocumentationFor(((TypeInfo)info).Name); if (m != null) { msg += "\r\n" + m; } } if (msg.Length > 0) { InsightWindow window = new InsightWindow(editor.TextArea); window.Content = msg; window.Show(); } } } } catch (Exception ex) { //deliberately swallow any exceptions here } } }
public static ClassificationTag GetTag(Irony.Parsing.Token token) { ClassificationTag tag = null; if (token.EditorInfo.Type == Irony.Parsing.TokenType.Identifier) { if (C != null && C.Contains(token.Text)) { tag = CTag; } else if (LuaFramework != null && LuaFramework.Contains(token.Text)) { tag = LuaFrameworkTag; } else if (UserTags != null) { for (int i = 0; i < UserTags.Count; i++) { if (Users[i].Contains(token.Text)) { tag = UserTags[i]; } } } if (m_table != null) { var mem = m_table.Members.Find((lm) => { return(lm is LuaFunction && lm.Name == token.Text); }); if (mem != null) { m_table = null; m_clear = false; if (tag == null) { tag = LuaFunctionTag; } } else if (m_clear == true) { m_table = null; m_clear = false; } else { m_clear = true; } } else if (IntellisenseHelper.ContainsFunction(token.Text)) { if (tag == null) { tag = LuaFunctionTag; } } else if ((m_table = IntellisenseHelper.GetTable(token.Text)) != null) { if (tag == null) { tag = LuaTableTag; } } } if (OtherTags.ContainsKey(token.EditorInfo.Type) && tag == null) { tag = OtherTags[token.EditorInfo.Type]; } return(tag); }
private void Button_Click(object sender, RoutedEventArgs e) { var name = TextBox_SettingName.Text.Trim(); if (string.IsNullOrWhiteSpace(name)) { System.Windows.MessageBox.Show(Properties.Resources.LoseSetName); TextBox_SettingName.Focus(); return; } else if (name.IndexOfAny(Path.GetInvalidFileNameChars()) != -1) { string strConfirm = string.Format("\"{0}\" is a invalid name, please rename.", name); System.Windows.MessageBox.Show(strConfirm, "Error"); TextBox_SettingName.Focus(); TextBox_SettingName.SelectAll(); return; } var luapath = TextBox_LuaPath.Text.Trim(); if (string.IsNullOrWhiteSpace(luapath) || !Directory.Exists(luapath)) { System.Windows.MessageBox.Show(Properties.Resources.InvalidLuaPath); TextBox_LuaPath.Focus(); TextBox_LuaPath.SelectAll(); return; } if (BabePackage.Setting.ContainsSetting(name)) { string strReplaceConfirm = string.Format("Setting \"{0}\" already exists, replace setting?", name); if (System.Windows.MessageBox.Show(strReplaceConfirm, "replace", MessageBoxButton.YesNo) != MessageBoxResult.Yes) { return; } BabePackage.Setting.AddSetting(name, luapath, TextBox_LuaExecutablePath.Text.Trim(), TextBox_WorkingPath.Text.Trim(), TextBox_CommandLine.Text.Trim(), (EncodingName)ComboBox_FileEncoding.SelectedItem); BabePackage.Setting.Save(); //如果保存的是当前选择工程且目录发生变化则重新加载 if (name == BabePackage.Setting.CurrentSetting && luapath != BabePackage.Setting.GetSetting(name).Folder) { IntellisenseHelper.Scan(); DTEHelper.Current.UpdateUI(); } } else { BabePackage.Setting.AddSetting(name, luapath, TextBox_LuaExecutablePath.Text.Trim(), TextBox_WorkingPath.Text.Trim(), TextBox_CommandLine.Text.Trim(), (EncodingName)ComboBox_FileEncoding.SelectedItem); BabePackage.Setting.Save(); } InitComboBox(); //当前选择项为空时,则选择保存的项 if (ComboBox_Settings.SelectedItem == null || string.IsNullOrWhiteSpace(ComboBox_Settings.SelectedItem.ToString())) { ComboBox_Settings.SelectedItem = name; } Button_Save.IsEnabled = false; }
public bool FillTable(String word, char dot, List <Completion> completions) { var count = completions.Count; var table = IntellisenseHelper.GetTable(word); if (table != null) { var result = table.GetFullMembers(); if (dot == '.') { foreach (var list in result) { foreach (LuaMember l in list.Value) { if (completions.Exists((cp) => { return(cp.DisplayText == l.Name); })) { continue; } completions.Add(new Completion( l.Name, l is LuaFunction ? l.ToString() : l.Name, string.Format("{0}{1}{2} {3}{4}", list.Key, dot, l.ToString(), GetMemberPath(l), l.Comment), //list.Key + dot + l.ToString() + l.Comment, _provider.GetImageSource(l.GetType()), "icon")); } } } else { foreach (var list in result) { foreach (LuaMember l in list.Value) { if (l is LuaFunction) { completions.Add(new Completion( l.Name, l.ToString(), string.Format("{0}{1}{2} {3}{4}", list.Key, dot, l.ToString(), GetMemberPath(l), l.Comment), //list.Key + dot + l.ToString() + l.Comment, _provider.GetImageSource(l.GetType()), "icon")); } } } } } else //找不到table。拿文件单词进行提示。 { var snapshot = _buffer.CurrentSnapshot; var tokens = FileManager.Instance.CurrentFileToken; var tempTable = new HashSet <String>(); foreach (LuaMember lm in tokens) { var point = LineAndColumnNumberToSnapshotPoint(snapshot, lm.Line, lm.Column); if (point > 0) { char preview = snapshot[point - 1]; if (preview == '.' || preview == ':') { if (tempTable.Contains(lm.Name)) { continue; } tempTable.Add(lm.Name); completions.Add(new Completion( lm.Name, lm.Name, string.Format("{0} {1}", lm.Name, GetMemberPath(lm)), //lm.Name, _provider.GetImageSource(lm.GetType()), "icon")); } } } } #if DEBUG System.Diagnostics.Debug.Print("fill items:" + (completions.Count - count)); #endif return(completions.Count > count); }
void editor_MouseHover(object sender, MouseEventArgs e) { TextViewPosition?pos = editor.GetPositionFromPoint(e.GetPosition(editor)); if (pos != null) { try { int line = pos.Value.Line; int offset = editor.Document.GetOffset(pos.Value.Location); Globals globs = IDEProject.inst().GlobalTypes; if (globs != null) { bool isFunc = false; string[] words = IntellisenseHelper.ExtractPath(editor.Document, offset, pos.Value.Location.Line, out isFunc); if (words != null && words.Length > 0) { TypeInfo info = null; FunctionInfo func = null; NameResolver reso = new NameResolver(globs, scanner); if (words.Length > 1) { for (int i = 0; i < words.Length; ++i) { if (i == words.Length - 1 && info != null && isFunc) { func = info.Functions.FirstOrDefault(f => f.Name.Equals(words[i])); } else { if (info == null) { info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, words[i]); } else if (info != null) { if (info.Properties.ContainsKey(words[i])) { info = info.Properties[words[i]]; } } } } } else if (isFunc && words.Length == 1) { func = globs.Functions.FirstOrDefault(f => f.Name.Equals(words[0])); } else if (!isFunc && words.Length == 1) { info = reso.GetClassType(editor.Document, line, words[0]); if (info == null) { KeyValuePair <string, TypeInfo> ty = globs.Classes.FirstOrDefault(p => p.Value.Equals(words[0])); if (ty.Value != null) { info = ty.Value; } } } string msg = ""; // Ask documentation for the information if (info != null && func != null) //member function { msg = func.ReturnType.Name + " " + func.Name; string m = IDEProject.inst().DocDatabase.GetDocumentationFor(info.Name + "::" + func.Name + func.Inner); if (m != null) { msg += "\r\n" + m; } } else if (func != null) //global function { msg = func.ReturnType.Name + " " + func.Name; string m = IDEProject.inst().DocDatabase.GetDocumentationFor(func.Name + func.Inner); if (m != null) { msg += "\r\n" + m; } } else if (info != null) //global or member type { msg = info.Name; string m = IDEProject.inst().DocDatabase.GetDocumentationFor(info.Name); if (m != null) { msg += "\r\n" + m; } } if (msg.Length > 0) { InsightWindow window = new InsightWindow(editor.TextArea); window.Content = msg; window.Show(); } } } } catch (Exception ex) { } } }
void editor_KeyUp(object sender, KeyEventArgs e) { // These keys halt and terminate intellisense switch (e.Key) { case Key.Home: case Key.End: case Key.Left: case Key.Right: case Key.Escape: case Key.LWin: case Key.RWin: case Key.Space: if (currentComp != null) { currentComp.Close(); } return; } // These keys halt further checks switch (e.Key) { case Key.Up: case Key.Down: case Key.PageDown: case Key.PageUp: case Key.LeftShift: case Key.RightShift: case Key.LeftAlt: case Key.RightAlt: case Key.LeftCtrl: case Key.RightCtrl: case Key.Scroll: case Key.Capital: case Key.CrSel: case Key.Clear: case Key.Insert: case Key.PrintScreen: case Key.Print: return; } char KEY = KeyHelpers.GetCharFromKey(e.Key); if (KEY == ')' || KEY == ';') { if (currentComp != null) { currentComp.Close(); } return; } int curOfs = editor.TextArea.Caret.Offset; int line = editor.TextArea.Caret.Line; // Do not attempt intellisense inside of comments string txt = editor.Document.GetText(editor.Document.Lines[editor.TextArea.Caret.Line - 1]); if (txt.Trim().StartsWith("//")) { return; } if (e.Key == Key.OemPeriod || KEY == ':') { //IntellisenseHelper.ResemblesDotPath(editor.Document, curOfs-1, line-1)) { int ofs = TextUtilities.GetNextCaretPosition(editor.Document, curOfs, LogicalDirection.Backward, CaretPositioningMode.WordStart); ofs = TextUtilities.GetNextCaretPosition(editor.Document, ofs, LogicalDirection.Backward, CaretPositioningMode.WordStart); string word = ""; for (; ofs < curOfs; ++ofs) { if (editor.Document.Text[ofs] != '.') { word += editor.Document.Text[ofs]; } } NameResolver reso = new NameResolver(IDEProject.inst().GlobalTypes, scanner); BaseTypeInfo info = null; string[] words = IntellisenseHelper.DotPath(editor.Document, curOfs - 1, line - 1); if (words.Length > 1) { for (int i = 0; i < words.Length - 1; ++i) { if (info == null) { info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, words[i]); } else if (info != null) { info = info.ResolvePropertyPath(IDEProject.inst().GlobalTypes, words[i]); //if (info.Properties.ContainsKey(words[i])) // info = info.Properties[words[i]]; } } } bool functionsOnly = false; //attempt to resolve it locally if (info == null) { info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, word); } //attempt to resolve it from globals if (info == null && IDEProject.inst().GlobalTypes != null && IDEProject.inst().GlobalTypes.Properties.ContainsKey(word)) { info = IDEProject.inst().GlobalTypes.Properties[word]; } if (info == null && word.Contains("::")) { if (IDEProject.inst().GlobalTypes == null) { return; } if (word.Length > 2) { if (IDEProject.inst().GlobalTypes.Classes.ContainsKey(word.Replace("::", ""))) { EnumInfo ti = IDEProject.inst().GlobalTypes.Classes[word.Replace("::", "")] as EnumInfo; if (ti != null) { currentComp = new CompletionWindow(editor.TextArea); IList <ICompletionData> data = currentComp.CompletionList.CompletionData; foreach (string str in ti.Values) { data.Add(new BaseCompletionData(null, str)); } currentComp.Show(); currentComp.Closed += comp_Closed; return; } else { TypeInfo ty = IDEProject.inst().GlobalTypes.Classes.FirstOrDefault(p => p.Key.Equals(word.Replace("::", ""))).Value; if (ty != null) { info = ty; functionsOnly = true; } } } else //list global functions { Globals globs = IDEProject.inst().GlobalTypes; currentComp = new CompletionWindow(editor.TextArea); IList <ICompletionData> data = currentComp.CompletionList.CompletionData; foreach (string str in globs.Properties.Keys) { data.Add(new PropertyCompletionData(globs.Properties[str], str)); } foreach (FunctionInfo fi in globs.Functions) { data.Add(new FunctionCompletionData(fi)); } currentComp.Show(); currentComp.Closed += comp_Closed; return; } } } //build the list if (info != null && info is TypeInfo) { TypeInfo ti = info as TypeInfo; currentComp = new CompletionWindow(editor.TextArea); IList <ICompletionData> data = currentComp.CompletionList.CompletionData; if (!functionsOnly) { foreach (string str in ti.Properties.Keys) { data.Add(new PropertyCompletionData(ti.Properties[str], str, ti.ReadonlyProperties.Contains(str))); } } foreach (FunctionInfo fi in ti.Functions) { data.Add(new FunctionCompletionData(fi)); } currentComp.Show(); currentComp.Closed += comp_Closed; } } else if (KEY == '(' && IntellisenseHelper.ResemblesDotPath(editor.Document, curOfs - 2, line - 1)) { NameResolver reso = new NameResolver(IDEProject.inst().GlobalTypes, scanner); TypeInfo info = null; FunctionInfo func = null; string[] words = IntellisenseHelper.DotPath(editor.Document, curOfs - 2, line - 1); if (words.Length > 1) { for (int i = 0; i < words.Length; ++i) { if (i == words.Length - 1 && info != null) { func = info.Functions.FirstOrDefault(f => f.Name.Equals(words[i])); } else { if (info == null) { info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, words[i]); } else if (info != null) { if (info.Properties.ContainsKey(words[i])) { info = info.Properties[words[i]]; } } } } } if (func != null) { List <FunctionInfo> data = new List <FunctionInfo>(); foreach (FunctionInfo fi in info.Functions.Where(f => { return(f.Name.Equals(func.Name)); })) { data.Add(fi); } if (data.Count > 0) { OverloadInsightWindow window = new OverloadInsightWindow(editor.TextArea); window.Provider = new OverloadProvider(info, data.ToArray()); window.Show(); //compWindow.Closed += comp_Closed; } } else if (func == null && info == null) // Found nothing { List <FunctionInfo> data = new List <FunctionInfo>(); foreach (FunctionInfo fi in IDEProject.inst().GlobalTypes.Functions.Where(f => { return(f.Name.Equals(words[1])); })) { data.Add(fi); } if (data.Count > 0) { OverloadInsightWindow window = new OverloadInsightWindow(editor.TextArea); window.Provider = new OverloadProvider(info, data.ToArray()); window.Show(); //compWindow.Closed += comp_Closed; } } } else if (Char.IsLetter(KEY)) { if (currentComp != null || editor.TextArea.Caret.Line == 1) { return; } int ofs = TextUtilities.GetNextCaretPosition(editor.Document, curOfs, LogicalDirection.Backward, CaretPositioningMode.WordStart); int nextOfs = TextUtilities.GetNextCaretPosition(editor.Document, ofs, LogicalDirection.Backward, CaretPositioningMode.WordStart); if (nextOfs > 0) { if (editor.Document.Text[nextOfs] == '.') { return; } } string word = ""; if (ofs < 0) { return; } for (; ofs < curOfs; ++ofs) { if (editor.Document.Text[ofs] != '.') { word += editor.Document.Text[ofs]; } } if (word.Contains(".")) { if (currentComp != null) { currentComp.Close(); } //editor_KeyUp(sender, e); return; } NameResolver reso = new NameResolver(IDEProject.inst().GlobalTypes, scanner); List <string> suggestions = new List <string>(); reso.GetNameMatch(editor.Document, editor.TextArea.Caret.Line - 1, word, ref suggestions); CompletionWindow compWindow = new CompletionWindow(editor.TextArea); compWindow.StartOffset = TextUtilities.GetNextCaretPosition(editor.Document, curOfs, LogicalDirection.Backward, CaretPositioningMode.WordStart); IList <ICompletionData> data = compWindow.CompletionList.CompletionData; //attempt local name resolution first if (suggestions.Count > 0) { foreach (string str in suggestions) //text suggestions are of lower priority { data.Add(new BaseCompletionData(null, str) { Priority = 0.5 }); } } //Scal globals if (IDEProject.inst().GlobalTypes != null) { foreach (string str in IDEProject.inst().GlobalTypes.Classes.Keys) { if (str.StartsWith(word)) { data.Add(new ClassCompletionData(IDEProject.inst().GlobalTypes.Classes[str])); } } foreach (FunctionInfo fun in IDEProject.inst().GlobalTypes.Functions) { if (fun.Name.StartsWith(word)) { data.Add(new FunctionCompletionData(fun)); } } } if (data.Count > 0) { currentComp = compWindow; currentComp.Show(); currentComp.Closed += comp_Closed; } } }
void dteEvents_OnBeginShutdown() { IntellisenseHelper.Stop(); }