Beispiel #1
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("");
 }
Beispiel #2
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);
 }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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);
 }
        async void MainLoopAsync(object sender, EventArgs e)
        {
            try
            {
                if (cancellationToken_.IsCancellationRequested)
                {
                    timer_.Stop();
                    return;
                }

                (bool pullEventOccurred, string text)result;
                try
                {
                    /*
                     * awaitでタスクの終了を待っている間に、タイマーイベントで繰り返し呼ばれタスクを生成し続けるため、タスクが終了するまでタイマーを止めている。
                     */
                    timer_.Stop();
                    result = await Task.Run(() => PullDiagnosticsText(), cancellationToken_);
                }
                finally
                {
                    timer_.Start();
                }

                if (result.pullEventOccurred == false)
                {
                    return;
                }
                if (result.text == null)
                {
                    if (outputPaneCleard_ == false)
                    {
                        HmOutputPane.Clear(hwndHidemaru_);
                        outputPaneCleard_ = true;
                    }
                }
                else
                {
                    HmOutputPane.Clear(hwndHidemaru_);
                    HmOutputPane.OutputW(hwndHidemaru_, result.text);
                    outputPaneCleard_ = false;
                }
            }
            catch (Exception exce)
            {
                logger_.Error(exce.ToString());
                timer_.Stop();
                throw;
            }
        }
Beispiel #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());
     }
 }
Beispiel #9
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);
 }
Beispiel #10
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);
 }
Beispiel #11
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);
 }
Beispiel #12
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);
 }
Beispiel #13
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("");
 }
Beispiel #14
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);
        }