Esempio n. 1
0
 /// <summary>
 /// front endを初期化する(非同期版)
 /// </summary>
 /// <param name="serverConfigFilename"></param>
 /// <param name="currentSourceCodeDirectory"></param>
 public void InitializeFrontEndServiceAsync(string fileExtension, string currentSourceCodeDirectory)
 {
     var _ = Task.Run(async() =>
     {
         try
         {
             var prevUpdateCount = iniFile_.UpdateCount;
             while (InitializeFrontEndServiceMain(fileExtension, currentSourceCodeDirectory) == false)
             {
                 //リトライする(.iniファイルの読み込み失敗、または、LSPのプロセス起動失敗)
                 while (true)
                 {
                     if (tokenSource_.IsCancellationRequested)
                     {
                         return;
                     }
                     var currentUpdateCount = iniFile_.UpdateCount;
                     if (prevUpdateCount != currentUpdateCount)
                     {
                         //.iniファイルが更新されたため再読み込みする
                         prevUpdateCount = currentUpdateCount;
                         break;
                     }
                     await Task.Delay(500);
                 }
             }
             //.iniファイル読み込み成功
         }catch (Exception e)
         {
             HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
             logger_?.Error(e.ToString());
         }
     }, tokenSource_.Token);
 }
Esempio n. 2
0
 internal string Hover(long hidemaruLine, long hidemaruColumn)
 {
     try {
         if (context_.worker == null)
         {
             return("");
         }
         var absFileName = FileProc();
         if (String.IsNullOrEmpty(absFileName))
         {
             return("");
         }
         long line, character;
         Hidemaru.HidemaruToZeroBase(out line, out character, hidemaruLine, hidemaruColumn);
         var hover = context_.worker.Hover(absFileName, line, character);
         if (hover == null)
         {
             return("");
         }
         return(hover.contents.value);
     }
     catch (Exception e)
     {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_.Error(e.ToString());
     }
     return("");
 }
Esempio n. 3
0
        public void Finalizer(int reason = 0)
        {
            logger_?.Trace("Enter Finalizer");
            try
            {
                tokenSource_?.Cancel();
                lock (context_)
                {
                    FinalizeContext();
                }
                UIThread.Finalizer();
            }
            catch (Exception e)
            {
                HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
                logger_?.Error(e.ToString());
            }

            diagnosticsTask_ = null;
            hoverTask_       = null;
            didChangeTask_   = null;

            dasmr_      = null;
            openedFile_ = null;

            /*tokenSource_ = null;
             * context_ = null;*/

            iniFile_ = null;

            logger_?.Trace("Leave Finalizer");
            logger_ = null;

            GC.Collect();
        }
Esempio n. 4
0
        /// <summary>
        /// front endの初期化が終了したか調べる
        /// </summary>
        /// <returns></returns>
        public bool CheckFrontEndService()
        {
            if (tokenSource_.IsCancellationRequested)
            {
                return(false);
            }
            bool token = false;

            try
            {
                Monitor.TryEnter(context_, ref token);
                if (token)
                {
                    if (context_.worker == null)
                    {
                        return(false);
                    }
                    return(true);
                }
            }catch (Exception e) {
                HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
                logger_?.Error(e.ToString());
            }
            finally{
                if (token)
                {
                    Monitor.Exit(context_);
                }
            }
            return(false);
        }
Esempio n. 5
0
 /// <summary>
 /// 秀丸エディタのテキストとサーバ側のテキストを明示的に同期する(デバッグ用途)
 /// </summary>
 /// <returns></returns>
 public bool SyncDocument()
 {
     try
     {
         var _ = FileProc();
     }catch (Exception e)
     {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_.Error(e.ToString());
         return(false);
     }
     return(true);
 }
Esempio n. 6
0
 public LocationContainerImpl Implementation(long hidemaruLine, long hidemaruColumn)
 {
     try {
         if (context_.worker == null)
         {
             return(null);
         }
         return(CommonImplementationsOfGoto(hidemaruLine, hidemaruColumn, context_.worker.Implementation, false));
     }catch (Exception e) {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_?.Error(e.ToString());
     }
     return(null);
 }
        public DiagnosticsTask(IWorker worker, ILspClientLogger logger, CancellationToken cancellationToken)
        {
            hwndHidemaru_     = Hidemaru.Hidemaru_GetCurrentWindowHandle();
            outputPaneCleard_ = false;

            worker_            = worker;
            logger_            = logger;
            cancellationToken_ = cancellationToken;

            timer_          = new System.Windows.Forms.Timer();
            timer_.Interval = 500;
            timer_.Tick    += MainLoopAsync;
            timer_.Start();
        }
Esempio n. 8
0
 public Service()
 {
     try
     {
         MicrosoftAppCenter.Start();
         tokenSource_ = new CancellationTokenSource();
         context_     = new Context();
         openedFile_  = new HidemaruEditorDocument();
         UIThread.Initializer();
         Hidemaru.Initialize();
     }catch (Exception e)
     {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_?.Error(e.ToString());
     }
 }
Esempio n. 9
0
            public Tooltipform(Service service, ILspClientLogger logger, CancellationToken cancellationToken)
            {
                service_      = service;
                hwndHidemaru_ = Hidemaru.Hidemaru_GetCurrentWindowHandle();

                logger_            = logger;
                cancellationToken_ = cancellationToken;

                SetFormAttr();
                SetLabelAttr();
                SetTimerAttr();
                //Memo:
                //Manual指定あり:formは意図した座標に表示される。
                //Manual指定なし:formをShow()したときにformが一瞬左上に表示される。
                this.StartPosition = FormStartPosition.Manual;
            }
Esempio n. 10
0
 public ServerCapabilitiesImpl ServerCapabilities()
 {
     if (context_.worker == null)
     {
         return(null);
     }
     try
     {
         return(new ServerCapabilitiesImpl(context_.worker.ServerCapabilities));
     }
     catch (Exception e)
     {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_.Error(e.ToString());
     }
     return(null);
 }
Esempio n. 11
0
 /// <summary>
 /// BackEndを初期化する(同期版)
 /// </summary>
 /// <param name="logFilename"></param>
 /// <returns></returns>
 public bool InitializeBackEndService()
 {
     try
     {
         if (!InitializeBackEndServiceMain())
         {
             Finalizer();
             return(false);
         }
         return(true);
     }catch (Exception e)
     {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_?.Error(e.ToString());
     }
     return(false);
 }
Esempio n. 12
0
 /// <summary>
 /// front endを初期化する(同期版)
 /// </summary>
 /// <param name="serverConfigFilename"></param>
 /// <param name="currentSourceCodeDirectory"></param>
 /// <returns></returns>
 public bool InitializeFrontEndService(string fileExtension, string currentSourceCodeDirectory)
 {
     try
     {
         var success = InitializeFrontEndServiceMain(fileExtension, currentSourceCodeDirectory);
         if (!success)
         {
             Finalizer();
             return(false);
         }
         return(true);
     }catch (Exception e)
     {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_?.Error(e.ToString());
     }
     return(false);
 }
Esempio n. 13
0
 /// <summary>
 /// BackEndを初期化する(非同期版)
 /// </summary>
 /// <param name="logFilename"></param>
 public void InitializeBackEndServiceAsync()
 {
     var _ = Task.Run(() => {
         try
         {
             if (InitializeBackEndServiceMain())
             {
                 return;
             }
             UIThread.Invoke((MethodInvoker) delegate
             {
                 Finalizer();
             });
         }catch (Exception e)
         {
             HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
             logger_?.Error(e.ToString());
         }
     }, tokenSource_.Token);
 }
Esempio n. 14
0
            /// <summary>
            /// Tooltipを表示すべきかどうか調べる
            /// </summary>
            /// <returns></returns>
            bool ShouldTooltipBeDisplayed()
            {
                if (!IsActiveWindowIsHidemaruMainWindow())
                {
                    return(false);
                }
                if (!IsUnderWindowIsCurrentProcessWindow())
                {
                    return(false);
                }

                // 自分が先頭ではない
                IntPtr hWnd = Hidemaru.Hidemaru_GetCurrentWindowHandle();
                var    list = GetWindowHidemaruHandleList();

                if (list.Count > 0 && list[0] != hWnd)
                {
                    return(false);
                }
                return(true);
            }
Esempio n. 15
0
 /// <summary>
 /// textDocument/completion
 /// </summary>
 /// <param name="absFilename"></param>
 /// <param name="hidemaruLine"></param>
 /// <param name="hidemaruColumn"></param>
 /// <returns>一時的な辞書ファイル名(ファイルはCOM側で一定時間後に削除します)</returns>
 public string Completion(long hidemaruLine, long hidemaruColumn)
 {
     if (context_.worker == null)
     {
         return("");
     }
     try
     {
         var absFileName = FileProc();
         if (String.IsNullOrEmpty(absFileName))
         {
             return("");
         }
         long line, character;
         Hidemaru.HidemaruToZeroBase(out line, out character, hidemaruLine, hidemaruColumn);
         return(context_.worker.Completion(absFileName, line, character));
     }
     catch (Exception e)
     {
         HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
         logger_.Error(e.ToString());
     }
     return("");
 }
Esempio n. 16
0
        public bool Initialize(string iniFileName)
        {
            //Memo: logger_はBackEndService起動後に取得可能
            try
            {
                iniFile_ = IniFileService.Create(iniFileName);
                if (iniFile_ == null)
                {
                    logger_?.Error(string.Format(".Ini file not found. iniFilename={0}", iniFileName));
                    return(false);
                }

                //CrashReport送信は個人情報に関わる処理なので処理の早い段階で真偽値をセットする
                MicrosoftAppCenter.EnableSendCrashReport = iniFile_.ReadEnableCrashReport();
                iniFile_.OnFileChanged += IniFile__OnFileChanged;

                return(true);
            }catch (Exception e)
            {
                HmOutputPane.OutputW(Hidemaru.Hidemaru_GetCurrentWindowHandle(), e.ToString());
                logger_?.Error(e.ToString());
            }
            return(false);
        }
Esempio n. 17
0
            // Zオーダー順に収められた秀丸ハンドルのリスト
            List <IntPtr> GetWindowHidemaruHandleList()
            {
                const uint    GW_HWNDPREV = 3;
                List <IntPtr> list        = new List <IntPtr>();
                IntPtr        hCurWnd     = Hidemaru.Hidemaru_GetCurrentWindowHandle();

                list.Add(hCurWnd);

                // 自分より前方を走査
                IntPtr hTmpWnd = hCurWnd;

                while (true)
                {
                    // 次のウィンドウ
                    hTmpWnd = GetWindow(hTmpWnd, GW_HWNDPREV);
                    if (hTmpWnd == IntPtr.Zero)
                    {
                        break;
                    }

                    // タブモードななので親があるハズ。(非タブモードだとそもそも1つしかない)
                    IntPtr hParent = GetParent(hTmpWnd);
                    if (hParent == IntPtr.Zero)
                    {
                        break;
                    }

                    // クラス名で判断
                    StringBuilder ClassName = new StringBuilder(256);
                    int           nRet      = GetClassName(hTmpWnd, ClassName, ClassName.Capacity);

                    if (ClassName.ToString().Contains(Hidemaru32Class_))
                    {
                        list.Insert(0, hTmpWnd);
                    }
                }

                // 一旦また自身のウィンドウハンドルにリセットして…
                hTmpWnd = hCurWnd;

                // 自分より後方を走査
                const uint GW_HWNDNEXT = 2;

                while (true)
                {
                    // 次のウィンドウ
                    hTmpWnd = GetWindow(hTmpWnd, GW_HWNDNEXT);
                    if (hTmpWnd == IntPtr.Zero)
                    {
                        break;
                    }

                    // タブモードななので親があるハズ。(非タブモードだとそもそも1つしかない)
                    IntPtr hParent = GetParent(hTmpWnd);
                    if (hParent == IntPtr.Zero)
                    {
                        break;
                    }

                    // クラス名で判断
                    StringBuilder ClassName = new StringBuilder(256);
                    int           nRet      = GetClassName(hTmpWnd, ClassName, ClassName.Capacity);

                    if (ClassName.ToString().Contains(Hidemaru32Class_))
                    {
                        list.Add(hTmpWnd);
                    }
                }

                return(list);
            }