private static IBSharpContext ParseContext(XElement xml) { var result = new BSharpContext(); result.Working = new List <IBSharpClass>(); foreach (var cls in xml.Elements("cls")) { var bcls = new BSharpClass(result); bcls.Set(BSharpClassAttributes.Built); bcls.Name = cls.Attr("name"); bcls.Namespace = cls.Attr("ns"); bcls.Compiled = cls.Elements().First(); result.Working.Add(bcls); } foreach (var error in xml.Elements("error")) { var e = new BSharpError { Type = error.Attr("type").To <BSharpErrorType>(), Message = error.Value }; var lexe = error.Element("lexinfo"); if (null != lexe) { e.LexInfo = new LexInfo(lexe.Attr("file"), lexe.Attr("line").ToInt()); } result.RegisterError(e); } result.BuildIndexes(); return(result); }
/// <summary> /// Ошибка импорта игнорируемого класса /// </summary> /// <returns></returns> public static BSharpError IgnoredImport(BSharpClass cls, IBSharpImport i) { return(new BSharpError { Level = ErrorLevel.Error, Phase = BSharpCompilePhase.ImportResolution, Type = BSharpErrorType.IgnoredImport, Data = i, ClassName = cls.FullName, Class = cls, Message = "Импортируемый класс является гнорируемым по признаку if" }); }
private void BuildClass(Graph g, IBSharpContext ctx, BSharpClass cls, IList<IBSharpClass> visited) { if (visited.Contains(cls)) return; visited.Add(cls); var label = cls.Name; if (!string.IsNullOrWhiteSpace(cls.Prototype)) { label = "[" + cls.Prototype + "]\r\n" + cls.Name; } var n = new Node {Code = cls.FullName, Label = label}; if (!string.IsNullOrWhiteSpace(cls.Namespace)) { n.SubgraphCode = (cls.Namespace.Replace(".", "__")) + "__"; } CheckoutNamespace(g,cls.Namespace); if (cls.Is(BSharpClassAttributes.Abstract)) { n.Shape = NodeShapeType.Box; n.FillColor = Color.Yellow; } g.AddNode(n); if (null != cls.DefaultImport) { g.AddEdge(new Edge {From = cls.FullName, To = cls.DefaultImport.FullName,Label = "0"}); BuildClass(g,ctx,(BSharpClass)cls.DefaultImport,visited); } int idx = 1; foreach (var i in cls.SelfImports) { g.AddEdge(new Edge {From = cls.FullName, To = i.Target.FullName,Label = (idx++).ToString()}); BuildClass(g, ctx, (BSharpClass)i.Target, visited); } foreach (var i in cls.IncludedClasses) { g.AddEdge(new Edge { From = cls.FullName, To = i.FullName, ArrowHead =ArrowType.Diamond}); BuildClass(g, ctx, (BSharpClass)i, visited); } foreach (var i in cls.ReferencedClasses) { g.AddEdge(new Edge { From = cls.FullName, To = i.FullName, ArrowHead = ArrowType.Vee,Color = Color.Blue}); BuildClass(g, ctx, (BSharpClass)i, visited); } foreach (var i in cls.LateIncludedClasses) { g.AddEdge(new Edge { From = cls.FullName, To = i.FullName, ArrowHead = ArrowType.ODiamond, Color = Color.Blue }); BuildClass(g, ctx, (BSharpClass)i, visited); } foreach (var i in cls.ReferencedDictionaries) { g.AddEdge(new Edge { From = cls.FullName, To = "d"+i, ArrowHead = ArrowType.Inv, Color = Color.Blue }); } }
private static IBSharpContext ParseContext(XElement xml) { var result = new BSharpContext(); result.Working = new List<IBSharpClass>(); foreach (var cls in xml.Elements("cls")) { var bcls = new BSharpClass(result); bcls.Set(BSharpClassAttributes.Built); bcls.Name = cls.Attr("name"); bcls.Namespace = cls.Attr("ns"); bcls.Compiled = cls.Elements().First(); result.Working.Add(bcls); } foreach (var error in xml.Elements("error")) { var e = new BSharpError {Type = error.Attr("type").To<BSharpErrorType>(), Message = error.Value}; var lexe = error.Element("lexinfo"); if (null != lexe) { e.LexInfo = new LexInfo(lexe.Attr("file"), lexe.Attr("line").ToInt()); } result.RegisterError(e); } result.BuildIndexes(); return result; }
/// <summary> /// Ошибка импорта игнорируемого класса /// </summary> /// <returns></returns> public static BSharpError IgnoredImport(BSharpClass cls, IBSharpImport i){ return new BSharpError{ Level = ErrorLevel.Error, Phase = BSharpCompilePhase.ImportResolution, Type = BSharpErrorType.IgnoredImport, Data = i, ClassName = cls.FullName, Class = cls, Message = "Импортируемый класс является гнорируемым по признаку if" }; }