void OnCompileFinished(ExpressionCompilerJob job)
        {
            if (!Enabled || job.UserData != (IntPtr)m_MostRecentUndoEntryId)
            {
                return;
            }

            if (job.Error == null)
            {
                SetPrevFinishedJob(job);
                m_CompileResultHandling = ECompileResultHandling.Success;
            }
            else
            {
                switch (m_CompileResultHandling)
                {
                case ECompileResultHandling.Success:
                    m_DelayedCompileErrorJob = job;
                    m_CompileResultHandling  = ECompileResultHandling.DelayedError;
                    UpdateDelayedCompileErrorDeadline();
                    break;

                case ECompileResultHandling.DelayedError:
                    m_DelayedCompileErrorJob = job;
                    break;

                case ECompileResultHandling.Error:
                    SetPrevFinishedJob(job);
                    break;
                }
            }
        }
 void Disable()
 {
     if (!Enabled)
     {
         return;
     }
     m_ErrorRecompileTimer.Stop();
     m_ExecFuncForceReEvaluateTimer.Stop();
     m_PrevFinishedJob = null;
     m_CompilerThread.Dispose();
     m_CompilerThread = null;
     UnderlineData    = new UnderlineDataContainer();
 }
        void Enable()
        {
            if (Enabled)
            {
                return;
            }
            m_CompilerThread = new ExpressionCompilerThread();
            m_ErrorRecompileTimer.Start();
            m_ExecFuncForceReEvaluateTimer.Start();

            m_PrevFinishedJob       = null;
            m_CompileResultHandling = ECompileResultHandling.Success;
            StartCompilation(-1);
        }
        void StartCompilation(int undo_entry_id)
        {
            m_MostRecentUndoEntryId = undo_entry_id;
            if (m_CompilerThread == null || m_ExpressionTextBox == null || m_CompileTimeConstants == null)
            {
                return;
            }

            Parser parser             = new Parser(m_ExpressionTextBox.Text, PackageGlobals.Instance().ExecFuncEvaluator, m_CompileTimeConstants);
            ExpressionCompilerJob job = new ExpressionCompilerJob(parser, PackageGlobals.Instance().CreateFreshEvalContext(), true, null);

            job.OnCompileFinished += OnCompileFinished;
            job.UserData           = (IntPtr)m_MostRecentUndoEntryId;
            m_CompilerThread.RemoveAllJobs();
            m_CompilerThread.AddJob(job);
        }
예제 #5
0
        void OnCompileFinished(ExpressionCompilerJob job)
        {
            if (m_VSMainWindow == null)
            {
                return;
            }
            m_ExpressionContainsExec = job.ContainsExec;
            Value title_value = job.EvalResult;

            if (title_value != null)
            {
                string title = title_value.ToString();
                m_VSMainWindow.SetTitle(title);
                Debug.WriteLine("Updating the titlebar");
            }
            else
            {
                m_VSMainWindow.SetTitle(m_VSMainWindow.OriginalTitle);
            }
        }
예제 #6
0
        private void UpdateWindowTitle()
        {
            m_VSMainWindow.Update();

            PackageGlobals globals           = PackageGlobals.Instance();
            EvalContext    eval_ctx          = globals.CreateFreshEvalContext();
            bool           variables_changed = !CompareVariables(eval_ctx.VariableValues, m_PrevVariableValues);

            if (variables_changed)
            {
                m_PrevVariableValues = eval_ctx.VariableValues;
                globals.TitleSetupEditor.Variables = eval_ctx.VariableValues;
            }

            ToolOptions options = (ToolOptions)GetDialogPage(typeof(ToolOptions));

#if VS2010_AND_LATER
            if (m_DebugPrintTitleControlHierarchyCount < 5 && options.Debug)
            {
                ++m_DebugPrintTitleControlHierarchyCount;
                m_VSMainWindow.DebugPrintTitleControlHierarchy();
            }
#endif

            PackageGlobals.VSMultiInstanceInfo multi_instance_info;
            globals.GetVSMultiInstanceInfo(out multi_instance_info);

            bool extension_active;
            switch (options.ExtensionActivationRule)
            {
            case EExtensionActivationRule.ActiveWithMultipleVSInstances:
                extension_active = multi_instance_info.multiple_instances;
                break;

            case EExtensionActivationRule.ActiveWithMultipleVSInstancesOfTheSameVersion:
                extension_active = multi_instance_info.multiple_instances_same_version;
                break;

            case EExtensionActivationRule.AlwaysInactive:
                extension_active = false;
                break;

            default:
                extension_active = true;
                break;
            }

            if (extension_active)
            {
                TitleSetup title_setup = globals.TitleSetup;
                if (m_ExpressionContainsExec || variables_changed || m_PrevExtensionActivationRule != options.ExtensionActivationRule ||
                    title_setup.TitleExpression != m_PrevTitleExpressionStr)
                {
                    Parser parser             = new Parser(title_setup.TitleExpression, globals.ExecFuncEvaluator, globals.CompileTimeConstants);;
                    ExpressionCompilerJob job = new ExpressionCompilerJob(parser, globals.CreateFreshEvalContext(), false, m_CompiledExpressionCache);
                    job.OnCompileFinished += OnCompileFinished;
                    m_ExpressionCompilerThread.RemoveAllJobs();
                    m_ExpressionCompilerThread.AddJob(job);
                }
                m_PrevTitleExpressionStr = title_setup.TitleExpression;
            }
            else
            {
                m_VSMainWindow.SetTitle(m_VSMainWindow.OriginalTitle);
            }

            m_PrevExtensionActivationRule = options.ExtensionActivationRule;
        }
 void SetPrevFinishedJob(ExpressionCompilerJob job)
 {
     m_PrevFinishedJob = job;
     UpdateWarningUnderlineData();
     UpdateCompileResultTextBox();
 }