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


C# Inside.HasFlag方法代码示例

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


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

示例1: Push

        public void Push(char ch)
        {
            if (readPreprocessorExpression) {
                wordBuf.Append(ch);
            }

            if (inside.HasFlag(Inside.VerbatimString) && pc == '"' && ch != '"') {
                inside &= ~Inside.StringLiteral;
            }
            switch (ch) {
                case '#':
                    if (IsLineStart)
                        inside = Inside.PreProcessor;
                    break;
                case '/':
                    if (IsInStringOrChar || IsInPreProcessorComment)
                        break;
                    if (pc == '/') {
                        if (inside.HasFlag(Inside.Comment)) {
                            inside |= Inside.DocComment;
                        } else {
                            inside |= Inside.Comment;
                        }
                    }
                    break;
                case '*':
                    if (IsInStringOrChar || IsInComment || IsInPreProcessorComment)
                        break;
                    if (pc == '/')
                        inside |= Inside.MultiLineComment;
                    break;
                case ' ':
                    currentIndent.Append(' ');
                    break;
                case '\t':
                    var nextTabStop = (col - 1 + textEditorOptions.IndentSize) / textEditorOptions.IndentSize;
                    col = 1 + nextTabStop * textEditorOptions.IndentSize;
                    currentIndent.Append('\t');
                    offset++;
                    return;
                case '\r':

                    if (readPreprocessorExpression) {
                        if (!eval(wordBuf.ToString()))
                            inside |= Inside.PreProcessorComment;
                    }

                    inside &= ~(Inside.Comment | Inside.String | Inside.CharLiteral | Inside.PreProcessor);
                    CheckKeyword(wordBuf.ToString());
                    wordBuf.Length = 0;
                    indent.Push(indentDelta);
                    indentDelta = new Indent(textEditorOptions);

                    if (addContinuation) {
                        indent.Push(IndentType.Continuation);
                    }
                    thisLineindent = indent.Clone();
                    addContinuation = false;
                    IsLineStart = true;
                    readPreprocessorExpression = false;
                    col = 1;
                    line++;
                    currentIndent.Length = 0;
                    break;
                case '\n':
                    if (pc == '\r')
                        break;
                    goto case '\r';
                case '"':
                    if (IsInComment || IsInPreProcessorComment)
                        break;
                    if (inside.HasFlag(Inside.StringLiteral)) {
                        if (pc != '\\')
                            inside &= ~Inside.StringLiteral;
                        break;
                    }

                    if (pc == '@') {
                        inside |= Inside.VerbatimString;
                    } else {
                        inside |= Inside.StringLiteral;
                    }
                    break;
                case '<':
                case '[':
                case '(':
                    if (IsInComment || IsInStringOrChar || IsInPreProcessorComment)
                        break;
                    parenStack.Push(new TextLocation(line, col));
                    popNextParenBlock = true;
                    indent.Push(IndentType.Block);
                    break;
                case '>':
                case ']':
                case ')':
                    if (IsInComment || IsInStringOrChar || IsInPreProcessorComment)
                        break;
                    if (popNextParenBlock && parenStack.Count > 0)
                        parenStack.Pop();
                    if (indent.Count > 0)
//.........这里部分代码省略.........
开发者ID:segaman,项目名称:NRefactory,代码行数:101,代码来源:CSharpIndentEngine.cs

示例2: Push

            public void Push(Inside inside, string keyword, int lineNum, int numSpaces)
            {
                StringBuilder indentBuilder;
                int sp = size - 1;
                Node node;
                int n = 0;

                indentBuilder = new StringBuilder();
                if((inside & (Inside.Attribute | Inside.ParenList)) != 0){
                    if(size > 0 && stack[sp].inside == inside){
                        while(sp >= 0) {
                            if(stack[sp].inside.HasFlag(Inside.FoldedOrBlock))
                                break;

                            sp--;
                        }
                        if(sp >= 0){
                            indentBuilder.Append(stack[sp].indent);
                            if(stack[sp].line_num == lineNum)
                                n = stack[sp].num_spaces;
                        }
                    }else{
                        while(sp >= 0){
                            if(stack[sp].inside.HasFlag(Inside.FoldedBlockOrCase)){
                                indentBuilder.Append(stack[sp].indent);
                                break;
                            }

                            sp--;
                        }
                    }
                    if(numSpaces - n <= 0){
                        indentBuilder.Append('\t');
                    }else{
                        indentBuilder.Append(' ', numSpaces - n);
                    }
                }else if(inside == Inside.MultiLineComment) {
                    if(size > 0){
                        indentBuilder.Append(stack[sp].indent);
                        if(stack[sp].line_num == lineNum)
                            n = stack[sp].num_spaces;
                    }

                    indentBuilder.Append(' ', numSpaces - n);
                }else if(inside == Inside.Case) {
                    while(sp >= 0){
                        if((stack[sp].inside & Inside.FoldedOrBlock) != 0){
                            indentBuilder.Append(stack[sp].indent);
                            break;
                        }

                        sp--;
                    }

                    //if(engine.policy.IndentSwitchBody)
                    //	indentBuilder.Append ('\t');

                    numSpaces = 0;
                }else if(inside.HasFlag(Inside.FoldedOrBlock)){
                    while(sp >= 0){
                        if(stack[sp].inside.HasFlag(Inside.FoldedBlockOrCase)){
                            indentBuilder.Append(stack[sp].indent);
                            break;
                        }

                        sp--;
                    }

                    Inside parent = size > 0 ? stack[size - 1].inside : Inside.Empty;

                    // This is a workaround to make anonymous methods indent nicely
                    if (parent == Inside.ParenList)
                        stack[size - 1].indent = indentBuilder.ToString ();

                    if (inside == Inside.FoldedStatement) {
                        indentBuilder.Append ('\t');
                    } else if (inside == Inside.Block) {
                        if (parent != Inside.Case || numSpaces != -1)
                            indentBuilder.Append ('\t');
                    }

                    numSpaces = 0;
                } else if (inside.HasFlag(Inside.StringOrChar)) {
                    // if these fold, do not indent
                    numSpaces = 0;

                    //pop regions back out
                    if (keyword == "region" || keyword == "endregion") {
                        for (; sp >= 0; sp--) {
                            if ((stack[sp].inside & Inside.FoldedBlockOrCase) != 0) {
                                indentBuilder.Append (stack[sp].indent);
                                break;
                            }
                        }
                    }
                } else if (inside == Inside.LineComment || inside == Inside.DocComment) {
                    // can't actually fold, but we still want to push it onto the stack
                    numSpaces = 0;
                } else {
                    // not a valid argument?
//.........这里部分代码省略.........
开发者ID:hazama-yuinyan,项目名称:monodevelop-bvebinding,代码行数:101,代码来源:BVEIndentEngineStack.cs


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