private void CollectHighlight(ABnfGuess target_guess, ABnfElement element, List <ALanguageHighlightWordInfo> list) { if (element is ALittleScriptPropertyValueCustomTypeElement || element is ALittleScriptVarAssignNameDecElement) { if (element.GetElementText() != m_key) { return; } var error = element.GuessType(out ABnfGuess guess); if (error != null) { return; } if (guess.GetValue() == target_guess.GetValue()) { var info = new ALanguageHighlightWordInfo(); info.start = element.GetStart(); info.end = element.GetEnd(); list.Add(info); } return; } if (element is ABnfNodeElement) { var childs = (element as ABnfNodeElement).GetChilds(); foreach (var child in childs) { CollectHighlight(target_guess, child, list); } } }
public override void QueryHighlightWordTag(List <ALanguageHighlightWordInfo> list) { if (m_method_dec == null) { ReloadInfo(); } var error = m_element.GuessType(out ABnfGuess guess); if (error != null) { return; } CollectHighlight(guess, m_method_body_dec, list); // 处理参数 if (m_method_dec != null) { var dec_list = ALittleScriptUtility.FindMethodParamNameDecList(m_method_dec, m_key); foreach (var dec in dec_list) { var info = new ALanguageHighlightWordInfo(); info.start = dec.GetStart(); info.end = dec.GetEnd(); list.Add(info); } } }
public override void QueryHighlightWordTag(List <ALanguageHighlightWordInfo> list) { ABnfLangFile file = m_element.GetFile() as ABnfLangFile; var value = m_element.GetElementText(); file.m_index.TryGetValue(value, out HashSet <ABnfNodeElement> set); if (set == null) { return; } foreach (var element in set) { var info = new ALanguageHighlightWordInfo(); info.start = element.GetStart(); info.end = element.GetEnd(); list.Add(info); } }
// 高亮标签 public void QueryHighlightWordTag(ABnfElement element, List <ALanguageHighlightWordInfo> info_list) { // 找到对应的配对 string value = element.GetElementText(); if (m_left_pairs.TryGetValue(value, out string right_pair)) { var parent = element.GetParent(); if (parent == null) { return; } // 找到所在的位置 var childs = parent.GetChilds(); int index = childs.IndexOf(element); if (index < 0) { return; } // 往后找到对应的匹配 for (int i = index + 1; i < childs.Count; ++i) { if (childs[i].GetElementText() == right_pair) { var info = new ALanguageHighlightWordInfo(); info.start = element.GetStart(); info.end = element.GetEnd(); info_list.Add(info); info = new ALanguageHighlightWordInfo(); info.start = childs[i].GetStart(); info.end = childs[i].GetEnd(); info_list.Add(info); break; } } return; } // 找到对应的配对 if (m_right_pairs.TryGetValue(value, out string left_pair)) { var parent = element.GetParent(); if (parent == null) { return; } // 找到所在的位置 var childs = parent.GetChilds(); int index = childs.IndexOf(element); if (index < 0) { return; } // 往前找到对应的匹配 for (int i = index - 1; i >= 0; --i) { if (childs[i].GetElementText() == left_pair) { var info = new ALanguageHighlightWordInfo(); info.start = element.GetStart(); info.end = element.GetEnd(); info_list.Add(info); info = new ALanguageHighlightWordInfo(); info.start = childs[i].GetStart(); info.end = childs[i].GetEnd(); info_list.Add(info); break; } } return; } ABnfNodeElement node = element as ABnfNodeElement; if (node == null) { node = element.GetParent(); } if (node == null) { return; } // 找到高亮配对 node.GetReference().QueryHighlightWordTag(info_list); }