本文整理汇总了C#中ASCompletion.Model.FileModel类的典型用法代码示例。如果您正苦于以下问题:C# FileModel类的具体用法?C# FileModel怎么用?C# FileModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileModel类属于ASCompletion.Model命名空间,在下文中一共展示了FileModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
//.........这里部分代码省略.........
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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"}));
}
}
示例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);
}
}
示例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);
//.........这里部分代码省略.........
示例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);
}
}