当前位置: 首页>>代码示例>>C#>>正文


C# CstNode.SafeParent方法代码示例

本文整理汇总了C#中CstNode.SafeParent方法的典型用法代码示例。如果您正苦于以下问题:C# CstNode.SafeParent方法的具体用法?C# CstNode.SafeParent怎么用?C# CstNode.SafeParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CstNode的用法示例。


在下文中一共展示了CstNode.SafeParent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProtectedIsAcceptedUsingOracle

 public override bool ProtectedIsAcceptedUsingOracle(CstNode node) {
     var p = node.Parent;
     var pp = p.Parent;
     var isPar = p.SafeName() == "parExpression";
     var isStmt = pp.SafeName() == "statement";
     if (isStmt && isPar && pp.FirstChild.SafeTokenText() == "if") {
         return true;
     }
     if (isStmt && isPar && pp.FirstChild.SafeTokenText() == "while") {
         return true;
     }
     if (isStmt && isPar && pp.FirstChild.SafeTokenText() == "do") {
         return true;
     }
     if (p.SafeName() == "forstatement"
         && p.Children().Count(e2 => e2.TokenText == ";") >= 2) {
         return true;
     }
     {
         var primary = node.SafeParent().SafeParent().SafeParent().SafeParent();
         if (primary.SafeName() != "primary") {
             return false;
         }
         //if (primary.Elements().All(e2 => e2.TokenText() != "Preconditions")) {
         //	return false;
         //}
         if (primary.Children().All(e2 => e2.TokenText != "checkArgument")) {
             return false;
         }
         //if (primary.NthElementOrDefault(0).SafeTokenText() != "Preconditions") {
         //	return false;
         //}
         //if (primary.NthElementOrDefault(2).SafeTokenText() != "checkArgument") {
         //	return false;
         //}
         if (node.PrevsFromFirst().Any()) {
             return false;
         }
         return true;
     }
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:41,代码来源:JavaExperiment.cs

示例2: ProtectedIsAcceptedUsingOracle

 public override bool ProtectedIsAcceptedUsingOracle(CstNode node) {
     var pName = node.SafeParent().FirstChild.Name;
     if (pName == "If") {
         return node.TokenText.ToLower() != "true";
     }
     if (pName == "While") {
         return node.TokenText.ToLower() != "true";
     }
     if (pName == "Do") {
         return node.TokenText.ToLower() != "true";
     }
     if (pName == "Switch") {
         return true;
     }
     if (node.Name == "casestatement" || node.Name == "defaultcase") {
         return true;
     }
     if (node.SafeParent().Name == "commaList"
         && node.SafeParent().SafeParent().Name == "forCondition"
         && !node.NextsFromSelf().Any()) {
         return node.TokenText.ToLower() != "true";
     }
     if (node.SafeParent().Name == "commaList"
         && node.SafeParent().SafeParent().Name == "simpleStatement"
         && node.SafeParent().SafeParent().FirstChild.Name == "Echo"
         && node.Prev == null) {
         return node.TokenText.ToLower() != "true";
     }
     return false;
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:30,代码来源:PhpExperiment.cs

示例3: ProtectedIsAcceptedUsingOracle

        //public override IEnumerable<SelectedFragment> RejectingFragments {
        //    get {
        //        return new[] {
        //            new SelectedFragment(13, @"for (; true;)", "true"),
        //            new SelectedFragment(@"while (true) {", "true"),
        //            new SelectedFragment(@"} while (true)", "true"),
        //            new SelectedFragment(@"if (true) {", "true"),
        //            new SelectedFragment(16, @"if (true) {", "true")
        //        };
        //    }
        //}

        public override bool ProtectedIsAcceptedUsingOracle(CstNode node) {
            var parentName = node.Parent.SafeName();
            if (parentName == "ifStatement") {
                return node.TokenText != "true";
            }
            if (parentName == "whileStatement") {
                return node.TokenText != "true";
            }
            if (parentName == "doWhileStatement") {
                return node.TokenText != "true";
            }
            if (parentName == "forStatement"
                && node.Prev == node.Parent.Children().First(e2 => e2.TokenText == ";")) {
                return node.TokenText != "true";
            }
            if (parentName == "switchStatement") {
                return true;
            }
            if (node.Name == "caseClause" || node.Name == "defaultClause") {
                return true;
            }
            var p = node.SafeParent().SafeParent();
            if (p.SafeName() == "callExpression" && p.FirstChild.TokenText == "console.log" &&
                p.Child("arguments").Child("assignmentExpression") == node) {
                return node.TokenText != "true";
            }
            return false;
        }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:40,代码来源:JavaScriptExperiment.cs

示例4: ProtectedIsAcceptedUsingOracle

 public override bool ProtectedIsAcceptedUsingOracle(CstNode node) {
     var ppp = node.SafeParent().SafeParent().SafeParent();
     var pppp = ppp.SafeParent();
     if (pppp.SafeName() == "functioncall" && ppp.Prev != null
         && ppp.Prev.TokenText == "print") {
         return true;
     }
     return false;
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:9,代码来源:LuaExperiment.cs


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