示例#1
0
 public static ReferenceStatement ToReferenceStatement(this ILine line)
 {
     var refStatement = new ReferenceStatement(Line: line)
     {
         ClientSideReference = line.GetReferencePath(),
     };
     return refStatement;
 }
示例#2
0
        private static void GetOutline(ILine line, List<ILine> OutputLines, ProcessedFile pf)
        {
            var statement = line as IOpenBraceStatement;
            if (statement == null)
            {
                if (line.IsReference())
                {
                    var refStatement = new ReferenceStatement(
                        Line: line,
                        ClientSideReference: line.GetReferencePath()
                    );
                    //var refStatement = line.ToReferenceStatement();
                    pf.References[refStatement.ClientSideReference] = refStatement;
                    OutputLines.Add(refStatement);
                }
                else
                {
                    OutputLines.Add(line);
                }
                return;
            }
            bool recurse = true;
            if (statement.IsInterface())
            {
                //var interfaceStatement = statement.ToInterface();
                var interfaceStatement = new Interface(
                    OpenBraceStatementBase: statement,
                    LiveStatementBase: statement.LiveStatementBase,
                    Line: statement.Line,
                    Name: statement.GetInterfaceName()
                );
                pf.Interfaces[interfaceStatement.Name] = interfaceStatement;
                interfaceStatement.Process();
                statement = interfaceStatement as IOpenBraceStatement;
                recurse = false;
            }
            else if (statement.IsFunction())
            {
                //var functionStatement = statement.ToFunction();
                var functionStatement = new StaticFunction(
                    OpenBraceStatementBase: statement,
                    LiveStatementBase:  statement.LiveStatementBase,
                    Line: statement.Line,
                    Name:  statement.GetFunctionName()
                );
                string functionName = functionStatement.GetFullName();
                pf.Functions[functionName] = functionStatement;
            }
            else if (statement.IsClass())
            {
                var classStatement = new Class(
                    OpenBraceStatementBase: statement,
                    LiveStatementBase: statement.LiveStatementBase,
                    Line: statement.Line,
                    Name: statement.GetClassName()
                );
                pf.Classes[classStatement.Name] = classStatement;
                statement = classStatement;
            }
            else if (statement.IsModule())
            {
                //var moduleStatement = statement.ToModule();
                var moduleStatement = new Module(
                    OpenBraceStatementBase: statement,
                    LiveStatementBase: statement.LiveStatementBase,
                    Line: statement.Line,
                    FullName: statement.FrontTrimmedLiveStatement.Trim('{').Trim()
                );
                pf.Modules[moduleStatement.FullName] = moduleStatement;
                statement = moduleStatement;
            }

            OutputLines.Add(statement);
            if (statement.Children != null && recurse)
            {
                var newc = new List<ILine>();
                foreach (var childLine in statement.Children)
                {
                    GetOutline(childLine, newc, pf);
                }
                statement.Children = newc;
            }
        }