本文整理汇总了C#中GetMemberOptions.StatementKeywords方法的典型用法代码示例。如果您正苦于以下问题:C# GetMemberOptions.StatementKeywords方法的具体用法?C# GetMemberOptions.StatementKeywords怎么用?C# GetMemberOptions.StatementKeywords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GetMemberOptions
的用法示例。
在下文中一共展示了GetMemberOptions.StatementKeywords方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetKeywordMembers
private IEnumerable<MemberResult> GetKeywordMembers(GetMemberOptions options, EnvironmentRecord scope) {
IEnumerable<string> keywords = null;
if (options.ExpressionKeywords()) {
// keywords available in any context
keywords = _exprKeywords;
} else {
keywords = Enumerable.Empty<string>();
}
if (options.StatementKeywords()) {
keywords = keywords.Union(_stmtKeywords);
}
return keywords.Select(kw => new MemberResult(name: kw, documentation: kw, type: JsMemberType.Keyword));
}
示例2: GetKeywordMembers
private IEnumerable<MemberResult> GetKeywordMembers(GetMemberOptions options, InterpreterScope scope)
{
IEnumerable<string> keywords = null;
if (options.ExpressionKeywords()) {
// keywords available in any context
keywords = PythonKeywords.Expression(ProjectState.LanguageVersion);
} else {
keywords = Enumerable.Empty<string>();
}
if (options.StatementKeywords()) {
keywords = keywords.Union(PythonKeywords.Statement(ProjectState.LanguageVersion));
}
if (!(scope is FunctionScope)) {
keywords = keywords.Except(PythonKeywords.InvalidOutsideFunction(ProjectState.LanguageVersion));
}
return keywords.Select(kw => new MemberResult(kw, PythonMemberType.Keyword));
}
示例3: GetKeywordMembers
private IEnumerable<MemberResult> GetKeywordMembers(GetMemberOptions options, InterpreterScope scope)
{
if (options.ExpressionKeywords()) {
// keywords available in any context
yield return new MemberResult("and", JMemberType.Keyword);
yield return new MemberResult("as", JMemberType.Keyword);
yield return new MemberResult("else", JMemberType.Keyword);
yield return new MemberResult("for", JMemberType.Keyword);
yield return new MemberResult("if", JMemberType.Keyword);
yield return new MemberResult("in", JMemberType.Keyword);
yield return new MemberResult("is", JMemberType.Keyword);
yield return new MemberResult("lambda", JMemberType.Keyword);
yield return new MemberResult("not", JMemberType.Keyword);
yield return new MemberResult("or", JMemberType.Keyword);
}
bool isStmtContext = options.StatementKeywords();
// and now the keywords...
if (scope is FunctionScope) {
if (isStmtContext) {
yield return new MemberResult("return", JMemberType.Keyword);
}
// yield is always available as an expression in 2.5+
yield return new MemberResult("yield", JMemberType.Keyword);
}
if (isStmtContext) {
// statement context only
yield return new MemberResult("assert", JMemberType.Keyword);
yield return new MemberResult("break", JMemberType.Keyword);
yield return new MemberResult("continue", JMemberType.Keyword);
yield return new MemberResult("class", JMemberType.Keyword);
yield return new MemberResult("def", JMemberType.Keyword);
yield return new MemberResult("del", JMemberType.Keyword);
yield return new MemberResult("elif", JMemberType.Keyword);
yield return new MemberResult("except", JMemberType.Keyword);
yield return new MemberResult("finally", JMemberType.Keyword);
yield return new MemberResult("from", JMemberType.Keyword);
yield return new MemberResult("global", JMemberType.Keyword);
yield return new MemberResult("import", JMemberType.Keyword);
yield return new MemberResult("pass", JMemberType.Keyword);
yield return new MemberResult("raise", JMemberType.Keyword);
yield return new MemberResult("try", JMemberType.Keyword);
yield return new MemberResult("while", JMemberType.Keyword);
yield return new MemberResult("with", JMemberType.Keyword);
}
if (ProjectState.LanguageVersion.Is7x()) {
yield return new MemberResult("False", JMemberType.Keyword);
yield return new MemberResult("None", JMemberType.Keyword);
yield return new MemberResult("True", JMemberType.Keyword);
// statement context only
if (isStmtContext) {
yield return new MemberResult("nonlocal", JMemberType.Keyword);
}
}
if (ProjectState.LanguageVersion.Is6x() && isStmtContext) {
// statement context only
yield return new MemberResult("exec", JMemberType.Keyword);
yield return new MemberResult("print", JMemberType.Keyword);
}
}