示例#1
0
        protected bool TypeIsVar(NRefactory.AstNode type)
        {
            var simpleType = type as NRefactory.SimpleType;

            if (simpleType != null)
            {
                return(simpleType.Identifier.Equals("var"));
            }

            return(false);
        }
 public bool TryGetInstruction(NRefactory.AstNode node, OpCode opCode, out Instruction instruction)
 {
     return(_instructionIndexer.TryGetInstruction(node, opCode, out instruction));
 }
 public Instruction GetInstruction(NRefactory.AstNode node)
 {
     return(_instructionIndexer.GetInstruction(node));
 }
示例#4
0
		protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
		{
			SimpleType o = other as SimpleType;
			return o != null && MatchString(this.Identifier, o.Identifier) && this.TypeArguments.DoMatch(o.TypeArguments, match);
		}
 public Instruction GetLastInstructionInRange(NRefactory.AstNode node)
 {
     return(_instructionIndexer.GetLastInstructionInRange(node));
 }
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            PrimitiveExpression o = other as PrimitiveExpression;

            return(o != null && (this.Value == AnyValue || object.Equals(this.Value, o.Value)));
        }
示例#7
0
 protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
 {
     return(other == null || other.IsNull);
 }
示例#8
0
        void FixOpenBrace(BraceStyle braceStyle, AstNode lbrace)
        {
            if (lbrace.IsNull)
            {
                return;
            }
            switch (braceStyle)
            {
            case BraceStyle.DoNotChange:
                return;

            case BraceStyle.BannerStyle:
            case BraceStyle.EndOfLine:
                var prev = lbrace.GetPrevNode(NoWhitespacePredicate);
                if (prev is PreProcessorDirective)
                {
                    return;
                }
                int prevOffset = document.GetOffset(prev.EndLocation);

                if (prev is Comment || prev is PreProcessorDirective)
                {
                    int next = document.GetOffset(lbrace.GetNextNode().StartLocation);
                    EnsureText(prevOffset, next, "");
                    while (prev is Comment || prev is PreProcessorDirective)
                    {
                        prev = prev.GetPrevNode();
                    }
                    prevOffset = document.GetOffset(prev.EndLocation);
                    AddChange(prevOffset, 0, " {");
                }
                else
                {
                    int braceOffset2 = document.GetOffset(lbrace.StartLocation);
                    EnsureText(prevOffset, braceOffset2, " ");
                }
                break;

            case BraceStyle.EndOfLineWithoutSpace:
                prev = lbrace.GetPrevNode(NoWhitespacePredicate);
                if (prev is PreProcessorDirective)
                {
                    return;
                }
                prevOffset = document.GetOffset(prev.EndLocation);
                int braceOffset = document.GetOffset(lbrace.StartLocation);
                EnsureText(prevOffset, braceOffset, "");
                break;

            case BraceStyle.NextLine:
                prev = lbrace.GetPrevNode(NoWhitespacePredicate);
                if (prev is PreProcessorDirective)
                {
                    return;
                }
                prevOffset  = document.GetOffset(prev.EndLocation);
                braceOffset = document.GetOffset(lbrace.StartLocation);
                EnsureText(prevOffset, braceOffset, options.EolMarker + curIndent.IndentString);
                break;

            case BraceStyle.NextLineShifted:
                prev = lbrace.GetPrevNode(NoWhitespacePredicate);
                if (prev is PreProcessorDirective)
                {
                    return;
                }
                prevOffset  = document.GetOffset(prev.EndLocation);
                braceOffset = document.GetOffset(lbrace.StartLocation);
                curIndent.Push(IndentType.Block);
                EnsureText(prevOffset, braceOffset, options.EolMarker + curIndent.IndentString);
                curIndent.Pop();
                break;

            case BraceStyle.NextLineShifted2:
                prev = lbrace.GetPrevNode(NoWhitespacePredicate);
                if (prev is PreProcessorDirective)
                {
                    return;
                }
                prevOffset  = document.GetOffset(prev.EndLocation);
                braceOffset = document.GetOffset(lbrace.StartLocation);
                curIndent.Push(IndentType.Block);
                EnsureText(prevOffset, braceOffset, options.EolMarker + curIndent.IndentString);
                curIndent.Pop();
                break;
            }
        }
示例#9
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            ArraySpecifier o = other as ArraySpecifier;

            return(o != null && this.Dimensions == o.Dimensions);
        }
示例#10
0
 static bool IsMember(AstNode nextSibling)
 {
     return(nextSibling != null && nextSibling.NodeType == NodeType.Member);
 }
示例#11
0
 void FixIndentation(AstNode node)
 {
     FixIndentation(node.StartLocation, 0);
 }
示例#12
0
 static bool NoWhitespacePredicate(AstNode arg)
 {
     return(!(arg is NewLineNode || arg is WhitespaceNode));
 }
示例#13
0
        void AdjustNewLineBlock(AstNode startNode, int targetNewLineCount)
        {
            var indentString = policy.EmptyLineFormatting == EmptyLineFormatting.Indent ? curIndent.IndentString : "";

            TextLocation newLineInsertPosition = startNode.EndLocation;
            var          node = startNode.NextSibling;
            int          currentNewLineCount = 0;

            // Check the existing newlines
            for (; currentNewLineCount < targetNewLineCount; node = node.NextSibling)
            {
                if (node is WhitespaceNode)
                {
                    continue;
                }
                if (!(node is NewLineNode))
                {
                    break;
                }
                newLineInsertPosition = node.EndLocation;
                currentNewLineCount++;
                if (policy.EmptyLineFormatting == EmptyLineFormatting.DoNotChange)
                {
                    if (node.NextSibling == null)
                    {
                        // end of file/block etc, nothing more to do but break before assigning null to node
                        break;
                    }
                    continue;
                }
                var isBlankLine = IsSpacing(document.GetLineByNumber(node.StartLocation.Line));
                if (!isBlankLine)
                {
                    // remove EOL whitespace if appropriate
                    if (policy.RemoveEndOfLineWhiteSpace)
                    {
                        var offset = document.GetOffset(node.StartLocation);
                        var start  = SearchWhitespaceStart(offset);
                        if (start != offset)
                        {
                            AddChange(start, offset - start, null);
                        }
                    }
                }
                else
                {
                    var actualIndent = GetIndentation(node.StartLocation.Line);
                    if (actualIndent != indentString)
                    {
                        var start = document.GetOffset(new TextLocation(node.StartLocation.Line, 0));
                        AddChange(start, actualIndent.Length, indentString);
                    }
                }
                if (node.NextSibling == null)
                {
                    // end of file/block etc, nothing more to do but break before assigning null to node
                    break;
                }
            }
            if (currentNewLineCount < targetNewLineCount)
            {
                // We need to add more newlines
                var builder = new StringBuilder();
                for (; currentNewLineCount < targetNewLineCount; currentNewLineCount++)
                {
                    if (currentNewLineCount > 0)
                    {
                        // Don't indent the first line in the block since that is not an empty line.
                        builder.Append(indentString);
                    }
                    builder.Append(options.EolMarker);
                }
                var offset = document.GetOffset(newLineInsertPosition);
                AddChange(offset, 0, builder.ToString());
            }
            else if (currentNewLineCount == targetNewLineCount && node is NewLineNode)
            {
                // Check to see if there are any newlines to remove
                var endNode = node.GetNextSibling(n => !(n is NewLineNode || n is WhitespaceNode));
                if (endNode != null)
                {
                    var startOffset = document.GetOffset(newLineInsertPosition);
                    var endOffset   = document.GetOffset(new TextLocation(endNode.StartLocation.Line, 0));
                    EnsureText(startOffset, endOffset, null);
                }
            }
        }
示例#14
0
 protected override void VisitChildren(AstNode node)
 {
     VisitChildrenToFormat(node, n => n.AcceptVisitor(this));
 }
示例#15
0
 public IParameterDataProvider CreateIndexerParameterDataProvider(int startOffset, IType type, IEnumerable <IProperty> accessibleIndexers, ICSharpCode.NRefactory.CSharp.AstNode resolvedNode)
 {
     return(null);
 }
示例#16
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            CSharpTokenNode o = other as CSharpTokenNode;

            return(o != null && !o.IsNull && !(o is CSharpModifierToken));
        }
示例#17
0
 public ToolTipData(ICSharpCode.NRefactory.CSharp.SyntaxTree unit, ICSharpCode.NRefactory.Semantics.ResolveResult result, ICSharpCode.NRefactory.CSharp.AstNode node, CSharpAstResolver file)
 {
     this.Unit     = unit;
     this.Result   = result;
     this.Node     = node;
     this.Resolver = file;
 }
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            Constraint o = other as Constraint;

            return(o != null && this.TypeParameter.DoMatch(o.TypeParameter, match) && this.BaseTypes.DoMatch(o.BaseTypes, match));
        }