private void TestParseConceptDeclarationInternal(Func <string, NativeXConceptDeclaration> parser) { Action <NativeXType> vt = t => { NativeXFunctionType ft = (NativeXFunctionType)t; Assert.AreEqual("bool", ((NativeXReferenceType)ft.ReturnType).ReferencedName); Assert.AreEqual(2, ft.Parameters.Count); Assert.AreEqual("int", ((NativeXReferenceType)ft.Parameters[0]).ReferencedName); Assert.AreEqual("int", ((NativeXReferenceType)ft.Parameters[1]).ReferencedName); }; Action <NativeXConceptDeclaration> vd_common = d => { Assert.AreEqual("Eq", d.Name); Assert.AreEqual("T", d.ConceptType.ParameterName); Assert.AreEqual(2, d.Functions.Count); Assert.AreEqual("Equal", d.Functions[0].Name); vt(d.Functions[0].Type); Assert.AreEqual("NotEqual", d.Functions[1].Name); vt(d.Functions[1].Type); }; Action <NativeXConceptDeclaration> vd1 = d => { Assert.IsNull(d.Linking); }; Action <NativeXConceptDeclaration> vd2 = d => { Assert.AreEqual("Utility", d.Linking.LinkingAssembly); Assert.AreEqual("Eq", d.Linking.LinkingSymbol); }; string d1 = "concept T : Eq{Equal = function bool(int,int); NotEqual = function bool(int,int);}"; string d2 = "concept T : Eq alias Utility.Eq{Equal = function bool(int,int); NotEqual = function bool(int,int);}"; { NativeXConceptDeclaration d = parser(d1); vd_common(d); vd1(d); } { NativeXConceptDeclaration d = parser(d2); vd_common(d); vd2(d); } { NativeXConceptDeclaration d = parser(g1 + d1); vg1(d); vd_common(d); vd1(d); } { NativeXConceptDeclaration d = parser(g2 + d2); vg2(d); vd_common(d); vd2(d); } }
protected IEnumerable <TextEditorPopupItem> CreatePopupInstanceFunctions(string conceptName, CodeScope scope) { NativeXConceptDeclaration concept = scope.Find(conceptName) as NativeXConceptDeclaration; if (concept != null && concept.Functions != null && concept.Functions.Count > 0) { Bitmap functionImage = Images.Function; var members = concept.Functions .Select(f => new TextEditorPopupItem() { Image = functionImage, Text = f.Name }); return(members); } return(new TextEditorPopupItem[] { }); }
protected IEnumerable <TextEditorPopupItem> CreatePopupConcepts(CodeScope scope) { Bitmap templateImage = null; List <TextEditorPopupItem> items = new List <TextEditorPopupItem>(); foreach (CodeNode node in scope.FindAllDistinct()) { NativeXConceptDeclaration conceptdecl = node as NativeXConceptDeclaration; if (conceptdecl != null && conceptdecl.Name != null) { items.Add(new TextEditorPopupItem() { Text = conceptdecl.Name, Image = (templateImage ?? (templateImage = Images.Template)) }); } } return(items); }
protected IEnumerable <TextEditorPopupItem> CreatePopupExpressions(CodeScope scope) { Bitmap functionImage = null; Bitmap memberImage = null; Bitmap templateImage = null; Bitmap parameterImage = null; List <TextEditorPopupItem> items = new List <TextEditorPopupItem>(); foreach (CodeNode node in scope.FindAllDistinct()) { { NativeXNameTypePair parameter = node as NativeXNameTypePair; if (parameter != null && parameter.Name != null) { items.Add(new TextEditorPopupItem() { Text = parameter.Name, Image = (parameterImage ?? (parameterImage = Images.Parameter)) }); } } { NativeXVariableStatement varstat = node as NativeXVariableStatement; if (varstat != null && varstat.Name != null) { items.Add(new TextEditorPopupItem() { Text = varstat.Name, Image = (memberImage ?? (memberImage = Images.Member)) }); } } { NativeXVariableDeclaration vardecl = node as NativeXVariableDeclaration; if (vardecl != null && vardecl.Name != null) { items.Add(new TextEditorPopupItem() { Text = vardecl.Name, Image = (memberImage ?? (memberImage = Images.Member)) }); } } { NativeXFunctionDeclaration funcdecl = node as NativeXFunctionDeclaration; if (funcdecl != null && funcdecl.Name != null) { items.Add(new TextEditorPopupItem() { Text = funcdecl.Name, Image = (functionImage ?? (functionImage = Images.Function)) }); } } { NativeXConceptDeclaration conceptdecl = node as NativeXConceptDeclaration; if (conceptdecl != null && conceptdecl.Name != null) { items.Add(new TextEditorPopupItem() { Text = conceptdecl.Name, Image = (templateImage ?? (templateImage = Images.Template)) }); } } } Bitmap keywordImage = Images.Keyword; string[] keywords = new string[] { "result", "cast", "exception", "true", "false", "null", "sizeof", "offsetof" }; items.AddRange( keywords.Select(k => new TextEditorPopupItem() { Text = k, Image = keywordImage })); return(items); }