private static void KeyDispatcher(object sender, EventArgs e) {
			LoggingService.EnterMethod();
			
			fEditor = sender as IOTAEditor;
			
			try {
				IOTAModule _Module = OtaUtils.GetCurrentModule();
				IOTAEditor _Editor = OtaUtils.GetEditorWithSourceEditor(_Module);

				if ((fEditor != null) && (_Editor != null) &&
				    _Editor.FileName == fEditor.FileName) 
				{
					IOTASourceEditor _SourceEditor = OtaUtils.GetCurrentSourceEditor();

					if (IsValidForAutoCompletion(_Module, _SourceEditor)) {
						//TODO: the above fails some time when a file is open without a project.
						TypingSpeeder.KeyChecker.GetKeyFrom(_SourceEditor).Accept(_SourceEditor);
					}
					else {
						LoggingService.Warn("not valid for AC");
					}
				} else {
					LoggingService.Warn("empty editor or wrong file");
				}
			} catch (Exception ex) {
				Lextm.Windows.Forms.MessageBoxFactory.Fatal(Name, ex);
				throw;
			} finally {
				fEditor = null;
			}
			LoggingService.LeaveMethod();
		}
示例#2
0
        /// <summary>
        /// Gets source editor from editor.
        /// </summary>
        /// <param name="module">Module</param>
        /// <param name="editor">Editor</param>
        /// <returns>null if wrong.</returns>
        public static IOTASourceEditor GetSourceEditorFromEditor(IOTAModule module, IOTAEditor editor)
        {
            if (module == null || editor == null)
            {
                return null;
            }
            IOTASourceEditor result;

            for (int i = 0; i < module.ModuleFileCount; i++)
            {
                IOTAEditor _Editor = module.ModuleFileEditors(i);

                if (_Editor.FileName == editor.FileName)
                {
                    result = _Editor as IOTASourceEditor;
                    if (result != null)
                    {
                        return result;
                    }
                }
            }

            return null;
        }