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

C# Ast.PythonAst类代码示例

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

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



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

示例1: AppendCodeString

        internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
            Target.AppendCodeString(res, ast, format);
            format.Append(
                res,
                format.SpaceBeforeIndexBracket,
                " ",
                "",
                this.GetProceedingWhiteSpace(ast)
            );

            res.Append('[');
            _index.AppendCodeString(
                res, 
                ast, 
                format, 
                format.SpaceWithinIndexBrackets != null ? format.SpaceWithinIndexBrackets.Value ? " " : "" : null
            );

            if (!this.IsMissingCloseGrouping(ast)) {
                format.Append(
                    res,
                    format.SpaceWithinIndexBrackets,
                    " ",
                    "",
                    this.GetSecondWhiteSpace(ast)
                );
                res.Append(']');
            }
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:29,代码来源:IndexExpression.cs


示例2: AppendCodeString

 internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format, string leadingWhiteSpace) {
     string kwOnlyText = this.GetExtraVerbatimText(ast);
     if (kwOnlyText != null) {
         if (leadingWhiteSpace != null) {
             res.Append(leadingWhiteSpace);
             res.Append(kwOnlyText.TrimStart());
             leadingWhiteSpace = null;
         } else {
             res.Append(kwOnlyText);
         }
     }
     bool isAltForm = this.IsAltForm(ast);
     if (isAltForm) {
         res.Append(leadingWhiteSpace ?? this.GetProceedingWhiteSpace(ast));
         res.Append('(');
         leadingWhiteSpace = null;
     }
     _error.AppendCodeString(res, ast, format, leadingWhiteSpace);
     if (this.DefaultValue != null) {
         res.Append(this.GetSecondWhiteSpace(ast));
         res.Append('=');
         this.DefaultValue.AppendCodeString(res, ast, format);
     }
     if (isAltForm && !this.IsMissingCloseGrouping(ast)) {
         res.Append(this.GetSecondWhiteSpace(ast));
         res.Append(')');
     }
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:28,代码来源:ErrorParameter.cs


示例3: EnumerateBody

        internal static IEnumerable<IScopeNode> EnumerateBody(PythonAst ast, Statement body, bool includeAssignments = true) {
            SuiteStatement suite = body as SuiteStatement;
            if (suite != null) {
                foreach (Statement stmt in suite.Statements) {
                    ClassDefinition klass = stmt as ClassDefinition;
                    if (klass != null) {
                        yield return new ClassScopeNode(klass);
                        continue;
                    }

                    FunctionDefinition func = stmt as FunctionDefinition;
                    if (func != null) {
                        yield return new FunctionScopeNode(func);
                        continue;
                    }

                    AssignmentStatement assign;
                    if (includeAssignments && (assign = stmt as AssignmentStatement) != null) {
                        foreach (var target in assign.Left) {
                            NameExpression name = target as NameExpression;
                            if (name != null) {
                                yield return new AssignmentScopeNode(ast, assign, name);
                            }
                        }
                    }
                }
            }
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:28,代码来源:AstScopeNode.cs


示例4: Walk

 public override bool Walk(PythonAst node) {
     if (_ast != node) {
         throw new InvalidOperationException("walking wrong AST");
     }
     _scope.Push(_members);
     return base.Walk(node);
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:7,代码来源:AstAnalysisWalker.cs


示例5: AppendCodeString

 internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
     if (this.IsAltForm(ast)) {
         this.AppendCodeString(res, ast, format, "", "", _item);
     } else {
         this.AppendCodeString(res, ast, format, "(", this.IsMissingCloseGrouping(ast) ? "" : ")", _item);
     }
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:7,代码来源:GeneratorExpression.cs


示例6: GetLeadingWhiteSpace

 public override string GetLeadingWhiteSpace(PythonAst ast) {
     var whitespace = this.GetListWhiteSpace(ast);
     if (whitespace != null && whitespace.Length > 0) {
         return whitespace[0];
     }
     return null;
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:7,代码来源:RelativeModuleName.cs


示例7: GetLeadingWhiteSpace

 public override string GetLeadingWhiteSpace(PythonAst ast) {
     var decorateWhiteSpace = this.GetNamesWhiteSpace(ast);
     if (decorateWhiteSpace != null && decorateWhiteSpace.Length > 0) {
         return decorateWhiteSpace[0];
     }
     return "";
 }
开发者ID:RussBaz,项目名称:PTVS,代码行数:7,代码来源:DecoratorStatement.cs


示例8: SetLeadingWhiteSpace

 public override void SetLeadingWhiteSpace(PythonAst ast, string whiteSpace) {
     if (this.IsAltForm(ast)) {
         Items[0].SetLeadingWhiteSpace(ast, whiteSpace);
     } else {
         base.SetLeadingWhiteSpace(ast, whiteSpace);
     }
 }
开发者ID:RussBaz,项目名称:PTVS,代码行数:7,代码来源:TupleExpression.cs


示例9: SetLeadingWhiteSpace

 public override void SetLeadingWhiteSpace(PythonAst ast, string whiteSpace) {
     var decorateWhiteSpace = this.GetNamesWhiteSpace(ast);
     if (decorateWhiteSpace != null && decorateWhiteSpace.Length > 0) {
         decorateWhiteSpace[0] = whiteSpace;
     }
     
 }
开发者ID:RussBaz,项目名称:PTVS,代码行数:7,代码来源:DecoratorStatement.cs


示例10: UpdateTree

        public void UpdateTree(PythonAst newAst, IAnalysisCookie newCookie) {
            lock (this) {
                if (_updatesPending > 0) {
                    _updatesPending--;
                }
                if (newAst == null) {
                    // there was an error in parsing, just let the waiter go...
                    if (_curWaiter != null) {
                        _curWaiter.Set();
                    }
                    _tree = null;
                    return;
                }

                _tree = newAst;
                _cookie = newCookie;

                if (_curWaiter != null) {
                    _curWaiter.Set();
                }
            }

            var newParse = OnNewParseTree;
            if (newParse != null) {
                newParse(this, EventArgs.Empty);
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:27,代码来源:ProjectEntry.cs


示例11: AppendCodeStringStmt

 internal override void AppendCodeStringStmt(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
     _left.AppendCodeString(res, ast, format);
     res.Append(this.GetProceedingWhiteSpace(ast));
     res.Append(_op.ToCodeString());
     res.Append('=');
     _right.AppendCodeString(res, ast, format);
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:7,代码来源:AugmentedAssignStatement.cs


示例12: AppendCodeString

        internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
            Expression left = _left;
            Expression right = _right;
            string op1, op2;

            if (Operator == PythonOperator.NotIn) {
                op1 = "not";
                if (!this.IsIncompleteNode(ast)) {
                    op2 = "in";
                } else {
                    op2 = null;
                }
            } else if (Operator == PythonOperator.IsNot) {
                op1 = "is";
                op2 = "not";
            } else if ((op1 = this.GetVerbatimImage(ast)) != null) {
                // operator image differs from the operator enum, for example <> is always NotEqual which is !=
                // so we store the verbatim image and use it here.
                op2 = null;
            } else {
                op1 = Operator.ToCodeString();
                op2 = null;
            }
            BinaryToCodeString(res, ast, format, this, _left, _right, op1, op2);
        }
开发者ID:RussBaz,项目名称:PTVS,代码行数:25,代码来源:BinaryExpression.cs


示例13: AppendCodeStringStmt

        internal override void AppendCodeStringStmt(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
            format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
            res.Append("with");
            var itemWhiteSpace = this.GetListWhiteSpace(ast);
            int whiteSpaceIndex = 0;
            for (int i = 0; i < _items.Length; i++) {
                var item = _items[i];
                if (i != 0) {
                    if (itemWhiteSpace != null) {
                        res.Append(itemWhiteSpace[whiteSpaceIndex++]);
                    }
                    res.Append(',');
                }

                item.ContextManager.AppendCodeString(res, ast, format);
                if (item.Variable != null) {
                    if (itemWhiteSpace != null) {
                        res.Append(itemWhiteSpace[whiteSpaceIndex++]);
                    } else {
                        res.Append(' ');
                    }
                    res.Append("as");
                    item.Variable.AppendCodeString(res, ast, format);
                }
            }

            _body.AppendCodeString(res, ast, format);
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:28,代码来源:WithStatement.cs


示例14: AppendCodeString

 internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
     format.ReflowComment(res, this.GetProceedingWhiteSpaceDefaultNull(ast));
     if (format.UseVerbatimImage) {
         res.Append(this.GetVerbatimImage(ast) ?? _name);
     } else {
         res.Append(_name);
     }
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:8,代码来源:NameExpression.cs


示例15: AstPythonParameterInfo

 public AstPythonParameterInfo(PythonAst ast, Parameter p) {
     Name = p.Name;
     Documentation = "";
     DefaultValue = p.DefaultValue?.ToCodeString(ast) ?? "";
     IsParamArray = p.Kind == ParameterKind.List;
     IsKeywordDict = p.Kind == ParameterKind.Dictionary;
     ParameterTypes = new IPythonType[0];
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:8,代码来源:AstPythonParameterInfo.cs


示例16: CoverageMapper

 public CoverageMapper(PythonAst ast, string filename, HashSet<int> hits) {
     _ast = ast;
     _filename = filename;
     GlobalScope = new CoverageScope(ast);
     CurScopes.Add(GlobalScope);
     _blockCount++;
     _hits = hits;
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:8,代码来源:CoverageMapper.cs


示例17: AstPythonType

        public AstPythonType(PythonAst ast, IPythonModule declModule, ClassDefinition def, string doc, LocationInfo loc) {
            _members = new Dictionary<string, IMember>();

            Name = def.Name;
            Documentation = doc;
            DeclaringModule = declModule;
            Mro = new IPythonType[0];
            Locations = new[] { loc };
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:9,代码来源:AstPythonType.cs


示例18: AppendCodeString

 internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
     format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
     res.Append('`');
     _expression.AppendCodeString(res, ast, format);
     if (!this.IsMissingCloseGrouping(ast)) {
         res.Append(this.GetSecondWhiteSpace(ast));
         res.Append('`');
     }
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:9,代码来源:BackQuoteExpression.cs


示例19: AppendCodeString

 internal override void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format) {
     _target.AppendCodeString(res, ast, format);
     res.Append(this.GetProceedingWhiteSpaceDefaultNull(ast));
     res.Append('.');
     if (!this.IsIncompleteNode(ast)) {
         res.Append(this.GetSecondWhiteSpaceDefaultNull(ast));
         res.Append(this.GetVerbatimImage(ast) ?? _name);
     }
 }
开发者ID:wenh123,项目名称:PTVS,代码行数:9,代码来源:MemberExpression.cs


示例20: OverviewWalker

        public OverviewWalker(ProjectEntry entry, AnalysisUnit topAnalysis, PythonAst tree) {
            _entry = entry;
            _curUnit = topAnalysis;

            _tree = tree;
            Debug.Assert(_tree != null);

            _scope = topAnalysis.Scope;
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:9,代码来源:OverviewWalker.cs



注:本文中的Microsoft.PythonTools.Parsing.Ast.PythonAst类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# DynamicDataDisplay.Plotter类代码示例发布时间:2022-05-26
下一篇:
C# Ast.Node类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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