Example #1
0
        public ViewItem(ITextView view, ABnfFactory factory, ABnf abnf, ProjectInfo project, uint item_id
                        , string full_path, string text, long version)
        {
            m_left_pairs.Add("(", ")");
            m_left_pairs.Add("[", "]");
            m_left_pairs.Add("<", ">");
            m_left_pairs.Add("{", "}");

            m_right_pairs.Add(")", "(");
            m_right_pairs.Add("]", "[");
            m_right_pairs.Add(">", "<");
            m_right_pairs.Add("}", "{");

            // 保存相关信息
            m_view      = view;
            m_factory   = factory;
            m_abnf      = abnf;
            m_project   = project;
            m_item_id   = item_id;
            m_full_path = full_path;

            UpdateText(view, text, version);
            UpdateError();
            UpdateReference();
        }
Example #2
0
        internal void InitProjectInfos(SVsServiceProvider provider, ABnfFactory factory)
        {
            if (factory == null)
            {
                return;
            }

            if (m_server != null)
            {
                return;
            }
            m_server = new ALanguageServer();
            m_server.Start(factory);

            if (m_cookie != 0)
            {
                return;
            }
            if (m_solution != null)
            {
                return;
            }
            m_solution = provider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (m_solution == null)
            {
                return;
            }

            m_dot_ext   = factory.GetDotExt();
            m_file_icon = factory.GetFileIcon();

            // 读取所有工程
            m_projects.Clear();
            Guid             rguidEnumOnlyThisType = new Guid();
            IEnumHierarchies ppenum = null;

            m_solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum);
            IVsHierarchy[] rgelt        = new IVsHierarchy[1];
            uint           pceltFetched = 0;

            while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1)
            {
                IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2;
                if (sccProject2 != null)
                {
                    string project_path = GetProjectPath(rgelt[0]);
                    if (project_path != null)
                    {
                        if (m_server != null)
                        {
                            m_server.AddTask(() => m_server.AddProjectInfo(project_path));
                        }
                        m_projects[rgelt[0]] = new UIProjectInfo(this, rgelt[0], project_path, m_dot_ext, m_file_icon);
                    }
                }
            }

            // 监听工程变化
            m_solution.AdviseSolutionEvents(this, out m_cookie);
        }
Example #3
0
 public ProjectInfo(ABnfFactory factory, ABnf abnf, string path)
 {
     // 保存基本信息
     m_dot_ext = factory.GetDotExt();
     m_factory = factory;
     m_abnf    = abnf;
     m_path    = path;
 }
Example #4
0
        protected int m_col             = 1;        // 所在列

        public ABnfElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset)
        {
            m_factory = factory;
            m_file    = file;
            m_line    = line;
            m_col     = col;
            m_start   = offset;
        }
Example #5
0
        public UIViewItem(ABnf abnf, ABnf abnf_ui, IWpfTextView view
                          , SVsServiceProvider provider, IVsEditorAdaptersFactoryService adapters_factory
                          , UIProjectInfo project, uint item_id, string full_path, ABnfFactory factory, string line_comment_begin)
        {
            m_left_pairs.Add("(", ")");
            m_left_pairs.Add("[", "]");
            m_left_pairs.Add("<", ">");
            m_left_pairs.Add("{", "}");

            m_right_pairs.Add(")", "(");
            m_right_pairs.Add("]", "[");
            m_right_pairs.Add(">", "<");
            m_right_pairs.Add("}", "{");

            // 保存相关信息
            m_abnf               = abnf;
            m_abnf_ui            = abnf_ui;
            m_factory            = factory;
            m_view               = view;
            m_buffer             = m_view.TextBuffer;
            m_provider           = provider;
            m_project            = project;
            m_item_id            = item_id;
            m_adapters_factory   = adapters_factory;
            m_full_path          = full_path;
            m_line_comment_begin = line_comment_begin;

            if (m_view.Properties.TryGetProperty("version", out long version))
            {
                m_view.Properties.RemoveProperty("version");
            }
            ++version;
            m_view.Properties.AddProperty("version", version);
            string text = m_view.TextBuffer.CurrentSnapshot.GetText().Clone() as string;

            string project_path = null;

            if (m_project != null)
            {
                project_path = m_project.GetProjectPath();
                m_project.AddViewItem(m_item_id, this);
            }
            if (m_view.Properties.TryGetProperty(nameof(ALanguageServer), out ALanguageServer server))
            {
                server.AddTask(() => server.UpdateViewContent(m_view, project_path, m_item_id, m_full_path, text, version));
            }

            m_view.TextBuffer.Changed += OnBufferChanged;
            m_view.GotAggregateFocus  += OnViewFocusIn;
            m_view.LostAggregateFocus += OnViewFocusOut;
        }
Example #6
0
 // 初始化参数
 public void Clear()
 {
     m_file    = null;
     m_factory = null;
     m_regex_skip.Clear();
     m_line_comment_skip.Clear();
     m_block_comment_skip.Clear();
     m_stat          = null;
     m_root          = null;
     m_line_comment  = null;
     m_block_comment = null;
     m_rule.Clear();
     m_symbol_check.Clear();
 }
        public void Start(ABnfFactory factory)
        {
            m_factory = factory;
            if (m_factory == null)
            {
                return;
            }
            m_abnf = ALanguageUtility.CreateABnf(m_factory);
            if (m_abnf == null)
            {
                return;
            }

            StartThread();
        }
Example #8
0
        // 加载文法
        public string Load(string buffer, ABnfFactory factory)
        {
            try
            {
                // 清理
                Clear();

                // 设置节点工厂
                m_factory = factory;
                if (m_factory == null)
                {
                    return("m_factory == null");
                }

                // 保存字符串内容
                m_rule.Load(buffer);

                // 保存特殊的规则
                m_root          = m_rule.FindRuleInfo("Root");
                m_line_comment  = m_rule.FindRuleInfo("LineComment");
                m_block_comment = m_rule.FindRuleInfo("BlockComment");

                var symbol_set = m_rule.GetSymbolSet();
                foreach (var symbol in symbol_set)
                {
                    foreach (var symbol_check in symbol_set)
                    {
                        if (symbol_check.StartsWith(symbol) &&
                            symbol_check.Length > symbol.Length)
                        {
                            if (!m_symbol_check.TryGetValue(symbol, out HashSet <char> set))
                            {
                                set = new HashSet <char>();
                                m_symbol_check.Add(symbol, set);
                            }
                            set.Add(symbol_check[symbol.Length]);
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                Clear();
                return(e.Message);
            }

            return(null);
        }
        // 创建abnf解析器
        public static ABnf CreateABnf(ABnfFactory factory)
        {
            var bytes = factory.LoadABnf();

            if (bytes == null)
            {
                return(null);
            }

            ABnf abnf = new ABnf();

            char[] chars = new char[bytes.Length];
            for (int i = 0; i < bytes.Length; ++i)
            {
                chars[i] = (char)bytes[i];
            }
            if (abnf.Load(new string(chars), factory) != null)
            {
                return(null);
            }
            return(abnf);
        }
 public ALittleScriptAccessModifierElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public ABnfRegexElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string value, Regex regex)
     : base(factory, file, line, col, offset, value)
 {
     m_regex = regex;
 }
 public ALittleScriptPropertyValueMethodTemplateElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public AProtobufEnumBodyElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
Example #14
0
 public ALittleScriptReflectCustomTypeElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
Example #15
0
 public ALittleScriptValueFactorStatElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public ABnfStringElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string value)
     : base(factory, file, line, col, offset, value)
 {
 }
 public ALittleScriptPrimitiveTypeElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
Example #18
0
 public ALittleScriptTemplateExtendsClassDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public ALittleScriptMethodReturnTailDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
Example #20
0
 public ALittleScriptDoWhileConditionElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public override ProjectInfo CreateProjectInfo(ABnfFactory factory, ABnf abnf, string path)
 {
     return(new AProtobufProjectInfo(factory, abnf, path));
 }
 public ALittleScriptStructOptionNameDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public ALittleScriptOpAssignExprElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
Example #24
0
        protected List <ABnfElement> m_childs = new List <ABnfElement>(); // 节点列表

        public ABnfNodeElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
            : base(factory, file, line, col, offset)
        {
            m_type = type;
        }
 public ALittleScriptForPairDecElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
Example #26
0
 public ALittleScriptGenericFunctorParamTailElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public AProtobufProjectInfo(ABnfFactory factory, ABnf abnf, string path)
     : base(factory, abnf, path)
 {
 }
 public ABnfLeafElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string value)
     : base(factory, file, line, col, offset)
 {
     m_value = value;
 }
 public AProtobufServiceOptionElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }
 public AProtobufMessageVarNameElement(ABnfFactory factory, ABnfFile file, int line, int col, int offset, string type)
     : base(factory, file, line, col, offset, type)
 {
 }