예제 #1
0
		ParserNode RootNode()
		{
			if ((!previousData.Match(Data.Data)) || (previousType != ContentType))
			{
				previousRoot = Parser.Parse(Data.Data, ContentType);
				previousData.SetValue(Data.Data);
				previousType = ContentType;
			}
			return previousRoot;
		}
예제 #2
0
파일: Parser.cs 프로젝트: xyandro/NeoEdit
		static public string Reformat(ParserNode node, string input, ParserType parserType)
		{
			switch (parserType)
			{
				case ParserType.HTML: return HTMLVisitor.Format(node, input);
				case ParserType.JSON: return JSONVisitor.Format(node, input);
				case ParserType.XML: return XMLVisitor.Format(node, input);
				default: throw new Exception("Unable to reformat this type");
			}
		}
예제 #3
0
		void Command_Content_Navigate(ParserNode.ParserNavigationDirectionEnum direction, bool shiftDown) => ContentReplaceSelections(GetSelectionNodes().SelectMany(node => node.Navigate(direction, shiftDown)));
예제 #4
0
		List<string> Print()
		{
			var parents = new List<ParserNode>();
			for (var parent = this; parent != null; parent = parent.Parent)
				parents.Insert(0, parent);
			var parentTypes = string.Join("->", parents.Select(node => node.Type));
			var attrs = string.Join(", ", attributes.Select(child => ($"{child.start}-{child.end} {child.Type} \"{(child.Text ?? "").Replace("\r", "").Replace("\n", "").Replace("\"", "\"\"")}\"")));
			var result = new List<string> { $"[{start}-{end}: {attrs} Path: \"{parentTypes}\"" };
			result.AddRange(children.SelectMany(child => child.Print()).Select(str => $" {str}"));
			if (result.Count == 1)
				result[0] += "]";
			else
				result.Add("]");
			return result;
		}