예제 #1
0
        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)));
        }
예제 #2
0
        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(kw, JsMemberType.Keyword)));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
            }
        }