• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Model.FileModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ASCompletion.Model.FileModel的典型用法代码示例。如果您正苦于以下问题:C# FileModel类的具体用法?C# FileModel怎么用?C# FileModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileModel类属于ASCompletion.Model命名空间,在下文中一共展示了FileModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ParseFile

		static public FileModel ParseFile(FileModel fileModel)
        {
            string src = "";
            // parse file
            if (fileModel.FileName.Length > 0)
            {
                if (File.Exists(fileModel.FileName))
                {
                    src = PluginCore.Helpers.FileHelper.ReadFile(fileModel.FileName);
                    ASFileParser parser = new ASFileParser();
                    fileModel.LastWriteTime = File.GetLastWriteTime(fileModel.FileName);
                    if (cachedPath != null)
                        cacheLastWriteTime = fileModel.LastWriteTime;
                    parser.ParseSrc(fileModel, src);
                }
                // the file is not available (for the moment?)
                else if (Path.GetExtension(fileModel.FileName).Length > 0)
                {
                    fileModel.OutOfDate = true;
                }
            }
            // this is a package
            else
            {
                // ignore
            }
            return fileModel;
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:28,代码来源:ASFileParser.cs


示例2: ParseFile_IdentifiersWithUnicodeChars

            public void ParseFile_IdentifiersWithUnicodeChars()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.as3.IdentifiersWithUnicodeCharsTest.as"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new AS3Context.Context(new AS3Context.AS3Settings());
                    var model = ASFileParser.ParseFile(srcModel);
                    var classModel = model.Classes[0];
                    Assert.AreEqual("Test", classModel.Name);
                    Assert.AreEqual(FlagType.Class, classModel.Flags & FlagType.Class);
                    Assert.AreEqual(2, classModel.LineFrom);
                    Assert.AreEqual(9, classModel.LineTo);
                    Assert.AreEqual(2, classModel.Members.Count);

                    var memberModel = classModel.Members[0];
                    Assert.AreEqual("thísIsVälid", memberModel.Name);
                    Assert.AreEqual("String", memberModel.Type);
                    Assert.AreEqual(FlagType.Function, memberModel.Flags & FlagType.Function);
                    Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
                    Assert.AreEqual(4, memberModel.LineFrom);
                    Assert.AreEqual(6, memberModel.LineTo);

                    memberModel = classModel.Members[1];
                    Assert.AreEqual("日本語文字ヴァリアブル", memberModel.Name);
                    Assert.AreEqual("Dynamic", memberModel.Type);
                    Assert.AreEqual(FlagType.Variable, memberModel.Flags & FlagType.Variable);
                    Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
                    Assert.AreEqual(8, memberModel.LineFrom);
                    Assert.AreEqual(8, memberModel.LineTo);
                }
            }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:31,代码来源:ASFileParserTests.cs


示例3: ParseFile_SimpleClass

 public void ParseFile_SimpleClass()
 {
     using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.as3.SimpleClassTest.as"))
     {
         var srcModel = new FileModel(resourceFile.DestinationFile);
         srcModel.Context = new AS3Context.Context();
         var model = ASFileParser.ParseFile(srcModel);
         Assert.AreEqual(3, model.Version);
         Assert.IsTrue(model.HasPackage);
         Assert.AreEqual("test.test", model.Package);
         Assert.AreEqual(1, model.Classes.Count);
         var classModel = model.Classes[0];
         Assert.AreEqual("Test", classModel.Name);
         Assert.AreEqual("test.test.Test", classModel.QualifiedName);
         Assert.AreEqual(FlagType.Class, classModel.Flags & FlagType.Class);
         Assert.AreEqual(Visibility.Public, classModel.Access & Visibility.Public);
         Assert.AreEqual(2, classModel.LineFrom);
         Assert.AreEqual(7, classModel.LineTo);
         Assert.AreEqual(1, classModel.Members.Count);
         var memberModel = classModel.Members[0];
         Assert.AreEqual("Test", memberModel.Name);
         Assert.AreEqual(FlagType.Function, memberModel.Flags & FlagType.Function);
         Assert.AreEqual(FlagType.Constructor, memberModel.Flags & FlagType.Constructor);
         Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
         Assert.AreEqual(4, memberModel.LineFrom);
         Assert.AreEqual(6, memberModel.LineTo);
     }
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:28,代码来源:ASFileParserTests.cs


示例4: ParseFile_OverrideFunction

 public void ParseFile_OverrideFunction()
 {
     using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.as3.OverrideFunctionTest.as"))
     {
         var srcModel = new FileModel(resourceFile.DestinationFile);
         srcModel.Context = new AS3Context.Context();
         var model = ASFileParser.ParseFile(srcModel);
         var classModel = model.Classes[0];
         Assert.AreEqual(2, classModel.Members.Count);
         var memberModel = classModel.Members[0];
         Assert.AreEqual("test1", memberModel.Name);
         var expectedFlags = FlagType.Function | FlagType.Override;
         Assert.AreEqual(expectedFlags, memberModel.Flags & expectedFlags);
         Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
         Assert.AreEqual(4, memberModel.LineFrom);
         Assert.AreEqual(7, memberModel.LineTo);
         memberModel = classModel.Members[1];
         Assert.AreEqual("test2", memberModel.Name);
         Assert.AreEqual(expectedFlags, memberModel.Flags & expectedFlags);
         Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
         Assert.AreEqual(9, memberModel.LineFrom);
         Assert.AreEqual(12, memberModel.LineTo);
     }
 }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:24,代码来源:ASFileParserTests.cs


示例5: ParseFile_GenericsWithObjectConstraints

            public void ParseFile_GenericsWithObjectConstraints()
            {
                using (
                    var resourceFile =
                        new TestFile("ASCompletion.Test_Files.parser.haxe.GenericsObjectConstraintTest.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);
                    Assert.AreEqual(3, model.Classes.Count);

                    var objectConstraintGeneric = model.Classes[0];
                    Assert.AreEqual(2, objectConstraintGeneric.LineFrom);
                    Assert.AreEqual(11, objectConstraintGeneric.LineTo);
                    Assert.AreEqual(FlagType.Class, objectConstraintGeneric.Flags & FlagType.Class);
                    Assert.AreEqual("TestObjectConstraint<T:({},Measurable)>", objectConstraintGeneric.FullName);
                    Assert.AreEqual("TestObjectConstraint", objectConstraintGeneric.Name);
                    Assert.AreEqual("<T:({},Measurable)>", objectConstraintGeneric.Template);
                    Assert.AreEqual(2, objectConstraintGeneric.Members.Count);
                    var member = objectConstraintGeneric.Members[0];
                    Assert.AreEqual("test1", member.Name);
                    Assert.AreEqual(4, member.LineFrom);
                    Assert.AreEqual(6, member.LineTo);
                    Assert.AreEqual("T", member.Type);
                    Assert.AreEqual(FlagType.Function, member.Flags & FlagType.Function);
                    Assert.AreEqual(2, member.Parameters.Count);
                    var arg = member.Parameters[0];
                    Assert.AreEqual("expected", arg.Name);
                    Assert.AreEqual("T", arg.Type);
                    arg = member.Parameters[1];
                    Assert.AreEqual("actual", arg.Name);
                    Assert.AreEqual("T", arg.Type);
                    member = objectConstraintGeneric.Members[1];
                    Assert.AreEqual("test2<K:({},Measurable)>", member.FullName);
                    Assert.AreEqual("test2", member.Name);
                    Assert.AreEqual("<K:({},Measurable)>", member.Template);
                    Assert.AreEqual(8, member.LineFrom);
                    Assert.AreEqual(10, member.LineTo);
                    Assert.AreEqual("K", member.Type);
                    Assert.AreEqual(FlagType.Function, member.Flags & FlagType.Function);
                    arg = member.Parameters[0];
                    Assert.AreEqual("expected", arg.Name);
                    Assert.AreEqual("K", arg.Type);
                    arg = member.Parameters[1];
                    Assert.AreEqual("actual", arg.Name);
                    Assert.AreEqual("K", arg.Type);

                    var fullConstraintGeneric = model.Classes[1];
                    Assert.AreEqual(13, fullConstraintGeneric.LineFrom);
                    Assert.AreEqual(22, fullConstraintGeneric.LineTo);
                    Assert.AreEqual(FlagType.Class, fullConstraintGeneric.Flags & FlagType.Class);
                    Assert.AreEqual("TestFullConstraint<T:({},Measurable),Z:(Iterable<String>,Measurable)>",
                        fullConstraintGeneric.FullName);
                    Assert.AreEqual("TestFullConstraint", fullConstraintGeneric.Name);
                    Assert.AreEqual("<T:({},Measurable),Z:(Iterable<String>,Measurable)>",
                        fullConstraintGeneric.Template);
                    Assert.AreEqual(2, fullConstraintGeneric.Members.Count);
                    member = fullConstraintGeneric.Members[0];
                    Assert.AreEqual("test1", member.Name);
                    Assert.AreEqual(15, member.LineFrom);
                    Assert.AreEqual(17, member.LineTo);
                    Assert.AreEqual("T", member.Type);
                    Assert.AreEqual(FlagType.Function, member.Flags & FlagType.Function);
                    Assert.AreEqual(2, member.Parameters.Count);
                    arg = member.Parameters[0];
                    Assert.AreEqual("expected", arg.Name);
                    Assert.AreEqual("T", arg.Type);
                    arg = member.Parameters[1];
                    Assert.AreEqual("actual", arg.Name);
                    Assert.AreEqual("Z", arg.Type);
                    member = fullConstraintGeneric.Members[1];
                    Assert.AreEqual("test2<K:({},Measurable),V:(Iterable<String>,Measurable)>", member.FullName);
                    Assert.AreEqual("test2", member.Name);
                    Assert.AreEqual("<K:({},Measurable),V:(Iterable<String>,Measurable)>", member.Template);
                    Assert.AreEqual(19, member.LineFrom);
                    Assert.AreEqual(21, member.LineTo);
                    Assert.AreEqual("K", member.Type);
                    Assert.AreEqual(FlagType.Function, member.Flags & FlagType.Function);
                    arg = member.Parameters[0];
                    Assert.AreEqual("expected", arg.Name);
                    Assert.AreEqual("K", arg.Type);
                    arg = member.Parameters[1];
                    Assert.AreEqual("actual", arg.Name);
                    Assert.AreEqual("V", arg.Type);

                    // TODO: There should be a space between 'function' and 'new'! There should be a separate test covering this error
                    var typeDefConstraintGeneric = model.Classes[2];
                    Assert.AreEqual(24, typeDefConstraintGeneric.LineFrom);
                    Assert.AreEqual(33, typeDefConstraintGeneric.LineTo);
                    Assert.AreEqual(FlagType.Class, typeDefConstraintGeneric.Flags & FlagType.Class);
                    Assert.AreEqual("TestTypeDefConstraint<T:({functionnew():Void;},Measurable)>", typeDefConstraintGeneric.FullName);
                    Assert.AreEqual("TestTypeDefConstraint", typeDefConstraintGeneric.Name);
                    Assert.AreEqual("<T:({functionnew():Void;},Measurable)>", typeDefConstraintGeneric.Template);
                    Assert.AreEqual(2, typeDefConstraintGeneric.Members.Count);
                    member = typeDefConstraintGeneric.Members[0];
                    Assert.AreEqual("test1", member.Name);
                    Assert.AreEqual(26, member.LineFrom);
                    Assert.AreEqual(28, member.LineTo);
                    Assert.AreEqual("T", member.Type);
                    Assert.AreEqual(FlagType.Function, member.Flags & FlagType.Function);
//.........这里部分代码省略.........
开发者ID:xeronith,项目名称:flashdevelop,代码行数:101,代码来源:ASFileParserTests.cs


示例6: ResolveDelegate

        private static MemberModel ResolveDelegate(string type, FileModel inFile)
        {
            foreach (MemberModel def in inFile.Members)
                if (def.Name == type && (def.Flags & FlagType.Delegate) > 0)
                    return def;

            if (type.IndexOf('.') < 0)
            {
                string dotType = '.' + type;
                MemberList imports = ASContext.Context.ResolveImports(inFile);
                foreach (MemberModel import in imports)
                    if (import.Type.EndsWith(dotType))
                    {
                        type = import.Type;
                        break;
                    }
            }

            MemberList known = ASContext.Context.GetAllProjectClasses();
            foreach (MemberModel def in known)
                if (def.Type == type && (def.Flags & FlagType.Delegate) > 0)
                    return def;
            return null;
        }
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:24,代码来源:ASGenerator.cs


示例7: AddClass

 private void AddClass(FileModel model, ClassModel curClass)
 {
     // avoid empty duplicates due to Haxe directives
     foreach(ClassModel aClass in model.Classes)
         if (aClass.Name == curClass.Name)
         {
             if (aClass.Members.Count == 0)
             {
                 model.Classes.Remove(aClass);
                 break;
             }
             else return;
         }
     model.Classes.Add(curClass);
 }
开发者ID:thecocce,项目名称:flashdevelop,代码行数:15,代码来源:ASFileParser.cs


示例8: ParseFile_SpecialClassesComments

            public void ParseFile_SpecialClassesComments()
            {
                using (
                    var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.SpecialClassesCommentsTest.hx")
                    )
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);
                    Assert.AreEqual(3, model.Classes.Count);

                    var classModel = model.Classes[0];
                    Assert.AreEqual("TypedefTest", classModel.Name);
                    Assert.AreEqual("\r * Some typedef custom comments\r ", classModel.Comments);
                    Assert.AreEqual(5, classModel.LineFrom);
                    Assert.AreEqual(11, classModel.LineTo);
                    Assert.AreEqual(FlagType.TypeDef, classModel.Flags & FlagType.TypeDef);
                    Assert.AreEqual(1, classModel.Members.Count);
                    var member = classModel.Members[0];
                    Assert.AreEqual(10, member.LineFrom);
                    Assert.AreEqual(10, member.LineTo);
                    Assert.AreEqual("age", member.Name);
                    Assert.AreEqual("Int", member.Type);
                    Assert.AreEqual("Java Style comments", member.Comments);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);

                    classModel = model.Classes[1];
                    Assert.AreEqual("EnumTest", classModel.Name);
                    Assert.AreEqual("\r * Some enum custom comments\r ", classModel.Comments);
                    Assert.AreEqual(16, classModel.LineFrom);
                    Assert.AreEqual(22, classModel.LineTo);
                    Assert.AreEqual(FlagType.Enum, classModel.Flags & FlagType.Enum);
                    Assert.AreEqual(1, classModel.Members.Count);
                    member = classModel.Members[0];
                    Assert.AreEqual(21, member.LineFrom);
                    Assert.AreEqual(21, member.LineTo);
                    Assert.AreEqual("Foo", member.Name);
                    //TODO: Add support for this!
                    //Assert.AreEqual("\r\t * Enum element comments\r\t ", member.Comments);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);

                    classModel = model.Classes[2];
                    Assert.AreEqual("AbstractInt", classModel.Name);
                    Assert.AreEqual("\r * Some abstract custom comments\r ", classModel.Comments);
                    Assert.AreEqual("Int", classModel.ExtendsType);
                    Assert.AreEqual(27, classModel.LineFrom);
                    Assert.AreEqual(34, classModel.LineTo);
                    Assert.AreEqual(FlagType.Abstract, classModel.Flags & FlagType.Abstract);
                    Assert.AreEqual(1, classModel.Members.Count);
                    member = classModel.Members[0];
                    Assert.AreEqual(31, member.LineFrom);
                    Assert.AreEqual(33, member.LineTo);
                    Assert.AreEqual("new", member.Name);
                    Assert.AreEqual("Java Style comments", member.Comments);
                }
            }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:56,代码来源:ASFileParserTests.cs


示例9: ParseFile_Comments

            public void ParseFile_Comments()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.CommentsTest.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);
                    Assert.AreEqual(1, model.Classes.Count);

                    var classModel = model.Classes[0];
                    Assert.AreEqual("Test", classModel.Name);
                    Assert.AreEqual("\r * Some custom comments\r ", classModel.Comments);
                    Assert.AreEqual(5, classModel.LineFrom);
                    Assert.AreEqual(19, classModel.LineTo);
                    Assert.AreEqual(FlagType.Class, classModel.Flags & FlagType.Class);
                    Assert.AreEqual(2, classModel.Members.Count);
                    var member = classModel.Members[0];
                    Assert.AreEqual(10, member.LineFrom);
                    Assert.AreEqual(10, member.LineTo);
                    Assert.AreEqual("Test", member.Name);
                    Assert.AreEqual("Java Style comments", member.Comments);
                    Assert.AreEqual(FlagType.Constructor, member.Flags & FlagType.Constructor);
                    Assert.AreEqual(Visibility.Public, member.Access & Visibility.Public);
                    member = classModel.Members[1];
                    Assert.AreEqual(15, member.LineFrom);
                    Assert.AreEqual(18, member.LineTo);
                    Assert.AreEqual("testAdd", member.Name);
                    Assert.AreEqual("Int", member.Type);
                    Assert.AreEqual("\r\t * Some method documentation\r\t ", member.Comments);
                    Assert.AreEqual(FlagType.Function, member.Flags & FlagType.Function);
                    Assert.AreEqual(Visibility.Public, member.Access & Visibility.Public);
                    Assert.AreEqual(2, member.Parameters.Count);
                }
            }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:34,代码来源:ASFileParserTests.cs


示例10: InitTopLevelElements

        /// <summary>
        /// Prepare Loom intrinsic known vars/methods/classes
        /// </summary>
        protected override void InitTopLevelElements()
        {
            string filename = "toplevel.ls";
            topLevel = new FileModel(filename);

            if (topLevel.Members.Search("this", 0, 0) == null)
                topLevel.Members.Add(new MemberModel("this", "", FlagType.Variable | FlagType.Intrinsic, Visibility.Public));
            if (topLevel.Members.Search("super", 0, 0) == null)
                topLevel.Members.Add(new MemberModel("super", "", FlagType.Variable | FlagType.Intrinsic, Visibility.Public));
            if (topLevel.Members.Search(features.voidKey, 0, 0) == null)
                topLevel.Members.Add(new MemberModel(features.voidKey, "", FlagType.Intrinsic, Visibility.Public));
            topLevel.Members.Sort();
        }
开发者ID:JoeRobich,项目名称:flashdevelop,代码行数:16,代码来源:Context.cs


示例11: ParseFile_AnonymousStructures

            public void ParseFile_AnonymousStructures()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.AnonymousStructuresTest.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);

                    Assert.AreEqual(1, model.Classes.Count);

                    var classModel = model.Classes[0];

                    Assert.AreEqual(2, classModel.Members.Count);

                    var member = classModel.Members[0];
                    Assert.AreEqual("start", member.Name);
                    Assert.AreEqual(1, member.LineFrom);
                    Assert.AreEqual(1, member.LineTo);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);
                    Assert.AreEqual("{x:Int, y:Int}", member.Type);

                    member = classModel.Members[1];
                    Assert.AreEqual("target", member.Name);
                    Assert.AreEqual(2, member.LineFrom);
                    Assert.AreEqual(2, member.LineTo);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);
                    Assert.AreEqual("{x:Int, y:Int}", member.Type);
                }
            }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:29,代码来源:ASFileParserTests.cs


示例12: ParseFile_ClassImplements

            public void ParseFile_ClassImplements()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.ImplementClassTest.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);

                    Assert.AreEqual(2, model.Classes.Count);
                    var classModel = model.Classes[0];
                    Assert.AreEqual("Test", classModel.Name);
                    Assert.AreEqual(Visibility.Public, classModel.Access);
                    Assert.AreEqual(FlagType.Class, classModel.Flags & FlagType.Class);
                    Assert.That(classModel.Implements, Is.EquivalentTo(new[] {"ITest"}));

                    classModel = model.Classes[1];
                    Assert.AreEqual("MultipleTest", classModel.Name);
                    Assert.AreEqual(Visibility.Public, classModel.Access);
                    Assert.AreEqual(FlagType.Class, classModel.Flags & FlagType.Class);
                    Assert.That(classModel.Implements, Is.EquivalentTo(new[] {"ITest", "ITest2", "ITest3"}));
                }
            }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:22,代码来源:ASFileParserTests.cs


示例13: ParseFile_WrongSyntaxCompilerMetaAfterVarWithNoType

            public void ParseFile_WrongSyntaxCompilerMetaAfterVarWithNoType()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.WrongSyntaxCompilerMetaAfterVarWithNoType.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);
                    var classModel = model.Classes[0];
                    Assert.AreEqual("WrongSyntaxMetadataTest", classModel.Name);
                    Assert.AreEqual(FlagType.Class, classModel.Flags & FlagType.Class);
                    Assert.AreEqual(2, classModel.LineFrom);
                    //I'd say this should be possible
                    //Assert.AreEqual(9, classModel.LineTo);
                    Assert.AreEqual(2, classModel.Members.Count);

                    var memberModel = classModel.Members[0];
                    Assert.AreEqual("func", memberModel.Name);
                    Assert.AreEqual(null, memberModel.Type);
                    var flags = FlagType.Variable;
                    Assert.AreEqual(flags, memberModel.Flags & flags);
                    Assert.AreEqual(Visibility.Private, memberModel.Access & Visibility.Private);
                    Assert.AreEqual(6, memberModel.LineFrom);
                    Assert.AreEqual(6, memberModel.LineTo);
                    Assert.AreEqual(" Dummy data to make sure this method keeps values at the end of the parsing ", memberModel.Comments);
                    Assert.AreEqual("dummy", memberModel.MetaDatas[0].Name);
                }
            }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:27,代码来源:ASFileParserTests.cs


示例14: ParseFile_TypeDefs

            public void ParseFile_TypeDefs()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.TypeDefsTest.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);
                    Assert.AreEqual(7, model.Classes.Count);

                    var aliasTypeDef = model.Classes[0];
                    Assert.AreEqual(2, aliasTypeDef.LineFrom);
                    Assert.AreEqual(2, aliasTypeDef.LineTo);
                    Assert.AreEqual(FlagType.TypeDef, aliasTypeDef.Flags & FlagType.TypeDef);
                    Assert.AreEqual("Array<Int>", aliasTypeDef.ExtendsType);
                    Assert.AreEqual("Alias", aliasTypeDef.FullName);

                    var iterableTypeDef = model.Classes[1];
                    Assert.AreEqual(4, iterableTypeDef.LineFrom);
                    Assert.AreEqual(6, iterableTypeDef.LineTo);
                    Assert.AreEqual(FlagType.TypeDef, iterableTypeDef.Flags & FlagType.TypeDef);
                    Assert.AreEqual("Iterable<T>", iterableTypeDef.FullName);
                    Assert.AreEqual("Iterable", iterableTypeDef.Name);
                    Assert.AreEqual("<T>", iterableTypeDef.Template);
                    Assert.AreEqual(1, iterableTypeDef.Members.Count);
                    var member = iterableTypeDef.Members[0];
                    Assert.AreEqual("iterator", member.Name);
                    Assert.AreEqual(5, member.LineFrom);
                    Assert.AreEqual(5, member.LineTo);
                    Assert.AreEqual("Iterator<T>", member.Type);
                    Assert.AreEqual(FlagType.Function, member.Flags & FlagType.Function);

                    var typeWithOptionalATypeDef = model.Classes[2];
                    Assert.AreEqual(8, typeWithOptionalATypeDef.LineFrom);
                    Assert.AreEqual(12, typeWithOptionalATypeDef.LineTo);
                    Assert.AreEqual(FlagType.TypeDef, typeWithOptionalATypeDef.Flags & FlagType.TypeDef);
                    Assert.AreEqual("TypeWithOptionalA", typeWithOptionalATypeDef.FullName);
                    Assert.AreEqual(3, typeWithOptionalATypeDef.Members.Count);
                    member = typeWithOptionalATypeDef.Members[0];
                    Assert.AreEqual("age", member.Name);
                    Assert.AreEqual(9, member.LineFrom);
                    Assert.AreEqual(9, member.LineTo);
                    Assert.AreEqual("Int", member.Type);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);
                    member = typeWithOptionalATypeDef.Members[1];
                    Assert.AreEqual("name", member.Name);
                    Assert.AreEqual(10, member.LineFrom);
                    Assert.AreEqual(10, member.LineTo);
                    Assert.AreEqual("String", member.Type);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);
                    member = typeWithOptionalATypeDef.Members[2];
                    Assert.AreEqual("phoneNumber", member.Name);
                    Assert.AreEqual(11, member.LineFrom);
                    Assert.AreEqual(11, member.LineTo);
                    Assert.AreEqual("String", member.Type);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);

                    var typeWithOptionalBTypeDef = model.Classes[3];
                    Assert.AreEqual(14, typeWithOptionalBTypeDef.LineFrom);
                    Assert.AreEqual(17, typeWithOptionalBTypeDef.LineTo);
                    Assert.AreEqual(FlagType.TypeDef, typeWithOptionalBTypeDef.Flags & FlagType.TypeDef);
                    Assert.AreEqual("TypeWithOptionalB", typeWithOptionalBTypeDef.FullName);
                    Assert.AreEqual(2, typeWithOptionalBTypeDef.Members.Count);
                    member = typeWithOptionalBTypeDef.Members[0];
                    Assert.AreEqual("optionalString", member.Name);
                    Assert.AreEqual(15, member.LineFrom);
                    Assert.AreEqual(15, member.LineTo);
                    Assert.AreEqual("String", member.Type);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);
                    member = typeWithOptionalBTypeDef.Members[1];
                    Assert.AreEqual("requiredInt", member.Name);
                    Assert.AreEqual(16, member.LineFrom);
                    Assert.AreEqual(16, member.LineTo);
                    Assert.AreEqual("Int", member.Type);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);

                    var singleLineTypeDef = model.Classes[4];
                    Assert.AreEqual(19, singleLineTypeDef.LineFrom);
                    Assert.AreEqual(19, singleLineTypeDef.LineTo);
                    Assert.AreEqual(FlagType.TypeDef, singleLineTypeDef.Flags & FlagType.TypeDef);
                    Assert.AreEqual("SingleLine", singleLineTypeDef.FullName);
                    Assert.AreEqual(2, singleLineTypeDef.Members.Count);
                    member = singleLineTypeDef.Members[0];
                    Assert.AreEqual("x", member.Name);
                    Assert.AreEqual(19, member.LineFrom);
                    Assert.AreEqual(19, member.LineTo);
                    Assert.AreEqual("Int", member.Type);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);
                    member = singleLineTypeDef.Members[1];
                    Assert.AreEqual("y", member.Name);
                    Assert.AreEqual(19, member.LineFrom);
                    Assert.AreEqual(19, member.LineTo);
                    Assert.AreEqual("Int", member.Type);
                    Assert.AreEqual(FlagType.Variable, member.Flags & FlagType.Variable);

                    var normalDefTypeDef = model.Classes[5];
                    Assert.AreEqual(21, normalDefTypeDef.LineFrom);
                    Assert.AreEqual(24, normalDefTypeDef.LineTo);
                    Assert.AreEqual(FlagType.TypeDef, normalDefTypeDef.Flags & FlagType.TypeDef);
                    Assert.AreEqual("NormalDef", normalDefTypeDef.FullName);
                    Assert.AreEqual(2, normalDefTypeDef.Members.Count);
//.........这里部分代码省略.........
开发者ID:xeronith,项目名称:flashdevelop,代码行数:101,代码来源:ASFileParserTests.cs


示例15: ParseFile_StringWithEscapedChars

            public void ParseFile_StringWithEscapedChars()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.EscapedStringsTest.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);

                    Assert.AreEqual(1, model.Classes.Count);
                    var classModel = model.Classes[0];

                    Assert.AreEqual(1, classModel.Members.Count);
                    var member = classModel.Members[0];
                    Assert.AreEqual("test", member.Name);
                    Assert.AreEqual("String", member.Type);
                    Assert.AreEqual(4, member.LineFrom);
                    Assert.AreEqual(6, member.LineTo);
                    Assert.AreEqual(2, member.Parameters.Count);
                    var param = member.Parameters[0];
                    Assert.AreEqual("arg", param.Name);
                    Assert.AreEqual("String", param.Type);
                    Assert.AreEqual("\"hello \\t\\r\\n\\\\\\\"\\\\\"", param.Value);
                    Assert.AreEqual(4, param.LineFrom);
                    Assert.AreEqual(4, param.LineTo);
                    param = member.Parameters[1];
                    Assert.AreEqual("arg2", param.Name);
                    Assert.AreEqual("String", param.Type);
                    Assert.AreEqual(@"'hello \t\r\n\\\\'", param.Value);
                    Assert.AreEqual(4, param.LineFrom);
                    Assert.AreEqual(4, param.LineTo);
                }
            }
开发者ID:xeronith,项目名称:flashdevelop,代码行数:32,代码来源:ASFileParserTests.cs


示例16: AddEvents

        private static void AddEvents(FileModel aFile, BlockModel docModel, bool targetAIR, bool targetFP10)
        {
            aFile.MetaDatas = new List<ASMetaData>();
            foreach (EventModel ev in docModel.Events)
            {
                if (!targetAIR && ev.IsAIR) continue;
                if (!targetFP10 && ev.IsFP10) continue;

                int p = ev.EventType.LastIndexOf('.');
                string type = ev.EventType.Substring(0, p);
                string pname = ev.EventType.Substring(p + 1);
                ClassModel eClass = getClass(type);
                if (eClass.IsVoid()) continue;
                string value = '"' + ev.Name + '"';
                if (eClass.Members.Items.Any<MemberModel>(item => item.Name == pname))
                {
                    ASMetaData meta = new ASMetaData("Event");
                    if (ev.Comment != null)
                        meta.Comments = "\r\n\t * " + ev.Comment + "\r\n\t * @eventType " + ev.EventType;
                    meta.ParseParams(String.Format("name=\"{0}\", type=\"{1}\"", ev.Name, type));
                    aFile.MetaDatas.Add(meta);
                }
            }
        }
开发者ID:heon21st,项目名称:flashdevelop,代码行数:24,代码来源:Program.cs


示例17: ParseFile_ComplexClass

            public void ParseFile_ComplexClass()
            {
                using (var resourceFile = new TestFile("ASCompletion.Test_Files.parser.haxe.ComplexClassTest.hx"))
                {
                    var srcModel = new FileModel(resourceFile.DestinationFile);
                    srcModel.Context = new HaXeContext.Context(new HaXeContext.HaXeSettings());
                    var model = ASFileParser.ParseFile(srcModel);
                    var classModel = model.Classes[0];
                    Assert.AreEqual("Test", classModel.Name);
                    Assert.AreEqual(FlagType.Class, classModel.Flags & FlagType.Class);
                    Assert.AreEqual(2, classModel.LineFrom);
                    Assert.AreEqual(49, classModel.LineTo);
                    Assert.AreEqual(15, classModel.Members.Count);

                    var memberModel = classModel.Members[0];
                    Assert.AreEqual("CONSTANT", memberModel.Name);
                    var flags = FlagType.Static | FlagType.Variable;
                    Assert.AreEqual(flags, memberModel.Flags & flags);
                    Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
                    Assert.AreEqual(4, memberModel.LineFrom);
                    Assert.AreEqual(4, memberModel.LineTo);

                    memberModel = classModel.Members[1];
                    Assert.AreEqual("id", memberModel.Name);
                    Assert.AreEqual("Int", memberModel.Type);
                    flags = FlagType.Variable;
                    Assert.AreEqual(flags, memberModel.Flags & flags);
                    Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
                    Assert.AreEqual(6, memberModel.LineFrom);
                    Assert.AreEqual(6, memberModel.LineTo);

                    memberModel = classModel.Members[2];
                    Assert.AreEqual("_name", memberModel.Name);
                    Assert.AreEqual("String", memberModel.Type);
                    flags = FlagType.Variable;
                    Assert.AreEqual(flags, memberModel.Flags & flags);
                    Assert.AreEqual(Visibility.Private, memberModel.Access & Visibility.Private);
                    Assert.AreEqual(8, memberModel.LineFrom);
                    Assert.AreEqual(8, memberModel.LineTo);

                    memberModel = classModel.Members[3];
                    Assert.AreEqual("ro", memberModel.Name);
                    Assert.AreEqual("Int", memberModel.Type);
                    flags = FlagType.Getter;
                    Assert.AreEqual(flags, memberModel.Flags & flags);
                    Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
                    Assert.AreEqual(10, memberModel.LineFrom);
                    Assert.AreEqual(10, memberModel.LineTo);
                    Assert.AreEqual(2, memberModel.Parameters.Count);
                    Assert.AreEqual("default", memberModel.Parameters[0].Name);
                    Assert.AreEqual("null", memberModel.Parameters[1].Name);

                    memberModel = classModel.Members[4];
                    Assert.AreEqual("wo", memberModel.Name);
                    Assert.AreEqual("Int", memberModel.Type);
                    flags = FlagType.Getter;
                    Assert.AreEqual(flags, memberModel.Flags & flags);
                    Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
                    Assert.AreEqual(12, memberModel.LineFrom);
                    Assert.AreEqual(12, memberModel.LineTo);
                    Assert.AreEqual(2, memberModel.Parameters.Count);
                    Assert.AreEqual("null", memberModel.Parameters[0].Name);
                    Assert.AreEqual("default", memberModel.Parameters[1].Name);

                    memberModel = classModel.Members[5];
                    Assert.AreEqual("x", memberModel.Name);
                    Assert.AreEqual("Int", memberModel.Type);
                    flags = FlagType.Getter;
                    Assert.AreEqual(flags, memberModel.Flags & flags);
                    Assert.AreEqual(Visibility.Public, memberModel.Access & Visibility.Public);
                    Assert.AreEqual(14, memberModel.LineFrom);
                    Assert.AreEqual(14, memberModel.LineTo);
                    Assert 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AST.Expr类代码示例发布时间:2022-05-24
下一篇:
C# Model.ClassModel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap