コード例 #1
0
ファイル: ParsedLine.cs プロジェクト: vchelaru/FlatRedBall
 public void SetFromParsedLine(ParsedLine otherParsedLine)
 {
     mCodeItems = otherParsedLine.mCodeItems;
 }
コード例 #2
0
 public void SetFromParsedLine(ParsedLine otherParsedLine)
 {
     mCodeItems = otherParsedLine.mCodeItems;
 }
コード例 #3
0
        public void TestParsedLine()
        {
            var parsedLine = new ParsedLine("this.DoSomething(firstArgument, secondArgument)");

            var match = parsedLine.GetMatchingBracketForBracketAtIndex(1);

            if (match != 5)
            {
                throw new Exception("The matching closing bracket code item index should be 5, but it's " + match);
            }

            parsedLine.ConsolidateMethodContents();

            if (parsedLine.CodeItems.Count != 2)
            {
                throw new Exception("There should only be 2 code items, but there are " + parsedLine.CodeItems.Count);
            }


            parsedLine = new ParsedLine("new Vector3()");

            if (parsedLine[1].CodeType == CodeType.MethodCall)
            {
                throw new Exception("The type should be a constructor, not method call");
            }

            parsedLine = new ParsedLine("x() + y");
            if (parsedLine.CodeItems.Count != 5)
            {
                throw new Exception("There should be 5 CodeItems in the parsed line");
            }

            parsedLine = new ParsedLine("x");
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 1)
            {
                throw new Exception("Error combining to expressions");
            }

            parsedLine = new ParsedLine("x.y.z");
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 1)
            {
                throw new Exception("Error combining to expressions");
            }

            parsedLine = new ParsedLine("x.y.z + a.b.c");
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 3)
            {
                throw new Exception("Error combining to expressions");
            }

            parsedLine = new ParsedLine("x()");
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 1)
            {
                throw new Exception("Error combining to expressions");
            }

            parsedLine = new ParsedLine("x().y");
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 1)
            {
                throw new Exception("Error combining to expressions");
            }

            parsedLine = new ParsedLine("x() + y");
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 3)
            {
                throw new Exception("Error combining to expressions");
            }


            parsedLine = new ParsedLine("x(3+4) + y");
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 3)
            {
                throw new Exception("Error combining to expressions");
            }

            parsedLine = new ParsedLine("ToolEmitters.FindByName().Emit;");
            parsedLine.ConsolidateMethodContents();
            parsedLine.CombineToExpressions();
            if (parsedLine.Count != 2)
            {
                throw new Exception("Error combining to expressions");
            }
        }