public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
                ISourceCode sourceCode, 
                Func<ElementTypeFilter, IEnumerable<IElement>> enumerate, 
                Violation violation, 
                CsElement csElement)
            {
                CsToken startToken = null;
                foreach (var token in from token in csElement.ElementTokens
                                      where violation.Line == token.Location.StartPoint.LineNumber
                                        && (token.CsTokenType == CsTokenType.OpenCurlyBracket 
                                            || token.CsTokenType == CsTokenType.CloseCurlyBracket)
                                      select token)
                {
                    if (token.CsTokenType == CsTokenType.OpenCurlyBracket)
                    {
                        startToken = token;
                        continue;
                    }

                    if (token.CsTokenType == CsTokenType.CloseCurlyBracket)
                    {
                        var sourceRange = new SourceRange(startToken.Location.StartPoint.LineNumber, startToken.Location.StartPoint.IndexOnLine + 1, token.Location.EndPoint.LineNumber, token.Location.EndPoint.IndexOnLine + 2);
                        yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
                    }
                }
            }
 private static void ExtractRemainingSelection(TextDocument ActiveDoc, SourceRange SelectRange)
 {
     // Extract Remaining Selection
     CodeRush.Selection.SelectRange(SelectRange);
     ExecuteRefactoring("Extract Method");
     ActiveDoc.ParseIfTextChanged();
 }
Exemple #3
0
 public Lexer(IErrorReporter errorReporter, string source)
 {
     _errorReporter = errorReporter;
     _source = source;
     _reader = new CharReader(source);
     _tokenRange = SourceRange.Empty;
 }
            public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
                ISourceCode sourceCode, 
                Func<ElementTypeFilter, IEnumerable<IElement>> enumerate, 
                Violation violation, 
                CsElement csElement)
            {
                SourcePoint? startPoint = null;
                SourcePoint? endPoint = null;
                foreach (var token in from token in csElement.ElementTokens
                                      where token.LineNumber == violation.Line && token.CsTokenType != CsTokenType.WhiteSpace
                                      select token)
                {
                    if (token.CsTokenType == CsTokenType.Namespace)
                    {
                        startPoint = endPoint = new SourcePoint(token.Location.StartPoint.LineNumber, token.Location.StartPoint.IndexOnLine + 1);
                    }
                    else if (token.CsTokenType == CsTokenType.OpenCurlyBracket || token.CsTokenType == CsTokenType.EndOfLine)
                    {
                        if (startPoint != null)
                        {
                            var sourceRange = new SourceRange(startPoint.Value, endPoint.Value);
                            yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
                        }

                        yield break;
                    }
                    else if (startPoint != null)
                    {
                        endPoint = new SourcePoint(token.Location.EndPoint.LineNumber, token.Location.EndPoint.IndexOnLine + 2);
                    }
                }
            }
        private void TemplateExpandWithCollapsedRegions_Execute(ExecuteEventArgs ea)
        {
            TextDocument ActiveDoc = CodeRush.Documents.ActiveTextDocument;

            using (ActiveDoc.NewCompoundAction("TemplateExpandWithCollapsedRegions"))
            {
                var LinesFromStart = CodeRush.Caret.Line;
                var LinesFromEnd = ActiveDoc.LineCount - LinesFromStart;

                DevExpress.CodeRush.Core.Action Action = CodeRush.Actions.Get("TemplateExpand");
                Action.DoExecute();

                // Calculate line range that template expanded into.
                SourceRange TemplateExpandRange = new SourceRange(new SourcePoint(LinesFromStart, 1),
                                              new SourcePoint(ActiveDoc.LineCount - LinesFromEnd,
                                                  ActiveDoc.GetLine(LinesFromEnd).Length - 1)
                    );
                // Reparse everything just in case.
                CodeRush.Documents.ParseActive();
                CodeRush.Documents.ActiveTextDocument.ParseIfTextChanged();

                // Execute a delayed collapse of all regions in the ExpansionRange
                RangeRegionCollapser Collapser = new RangeRegionCollapser(TemplateExpandRange);
                Collapser.PerformDelayedCollapse(150);

            }
        }
        public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
            ISourceCode sourceCode,
            Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
            Violation violation,
            CsElement csElement)
        {
            CodePoint startPoint = null;
            CodePoint endPoint = null;
            foreach (var token in from token in csElement.ElementTokens
                                  where token.LineNumber >= violation.Line
                                  select token)
            {
                if (token.CsTokenType == CsTokenType.UsingDirective || token.CsTokenType == CsTokenType.Using)
                {
                    startPoint = token.Location.StartPoint;
                    continue;
                }

                if (token.CsTokenType == CsTokenType.Semicolon)
                {
                    endPoint = token.Location.EndPoint;
                }

                if (startPoint != null && endPoint != null)
                {
                    var sourceRange = new SourceRange(startPoint.LineNumber, startPoint.IndexOnLine + 1, endPoint.LineNumber, endPoint.IndexOnLine + 2);
                    yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
                }
            }
        }
 public ResTypeVarRef(
     SourceRange range,
     IResTypeParamDecl varDecl)
 {
     _range = range;
     _varDecl = varDecl;
 }
Exemple #8
0
 public Token(string text, TokenId tokenId, int pos, SourceRange range)
 {
     _text = text;
     _tokenId = tokenId;
     _pos = pos;
     _range = range;
 }
            public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
                ISourceCode sourceCode, 
                Func<ElementTypeFilter, IEnumerable<IElement>> enumerate, 
                Violation violation, 
                CsElement csElement)
            {
                int prefixLength = "The call to ".Length;
                var memberName = violation.Message.Substring(prefixLength, violation.Message.IndexOf(" must") - prefixLength);
                var thisFound = false;
                foreach (var token in from token in csElement.ElementTokens
                                      where token.LineNumber == violation.Line && token.CsTokenType != CsTokenType.WhiteSpace
                                      select token)
                {
                    if (token.CsTokenType == CsTokenType.This || (thisFound && token.Text == "."))
                    {
                        thisFound = true;
                    }
                    else
                    {
                        if (token.Text == memberName && !thisFound)
                        {
                            var sourceRange = new SourceRange(token.Location.StartPoint.LineNumber, token.Location.StartPoint.IndexOnLine + 1, token.Location.EndPoint.LineNumber, token.Location.EndPoint.IndexOnLine + 2);
                            yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
                        }

                        thisFound = false;
                    }
                }
            }
 public ResExp(
     SourceRange range,
     IResTypeExp type)
 {
     _range = range;
     _type = type;
 }
        public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
            ISourceCode sourceCode,
            Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
            Violation violation,
            CsElement csElement)
        {
            var preprocessorToken = (from token in csElement.ElementTokens
                         where token.LineNumber == violation.Line && token.CsTokenType == CsTokenType.PreprocessorDirective
                         select token).FirstOrDefault();
            if (preprocessorToken != null)
            {
                int underlineLength = 1;
                while (preprocessorToken.Text[underlineLength] == ' ' || preprocessorToken.Text[underlineLength] == '\t')
                {
                    underlineLength++;
                }

                while (underlineLength < preprocessorToken.Text.Length && preprocessorToken.Text[underlineLength] != ' ' && preprocessorToken.Text[underlineLength] != '\t')
                {
                    underlineLength++;
                }

                var startPoint = preprocessorToken.Location.StartPoint;
                var sourceRange = new SourceRange(startPoint.LineNumber, startPoint.IndexOnLine + 1, startPoint.LineNumber, startPoint.IndexOnLine + 1 + underlineLength);
                yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
            }
        }
 private static ElementEnumerable GetPrimitives(SourceRange SelectRange)
 {
     // Find all literals in SelectRange.
     var RangePrimitives = new ElementEnumerable(CodeRush.Source.ActiveFileNode,
         new TypeInRangeFilter(LanguageElementType.PrimitiveExpression,
           SelectRange), true);
     return RangePrimitives;
 }
 public ResVarDecl(
     SourceRange range,
     Identifier name,
     IResTypeExp type,
     ResVarFlags flags = ResVarFlags.None)
     : this(range, name, Lazy.Value(type), flags)
 {
 }
 public ResVarRef(
     SourceRange range,
     IResVarDecl varDecl,
     IResTypeExp type)
     : base(range, type)
 {
     _varDecl = varDecl;
 }
 public MidBreakExp(
     SourceRange range,
     MidLabel label,
     MidVal value)
     : base(range, new MidVoidType())
 {
     _label = label;
     _value = value;
 }
 public ResLabel(
     SourceRange range,
     Identifier name,
     IResTypeExp type)
 {
     _range = range;
     _name = name;
     _type = type;
 }
 public MidBuiltinApp(
     SourceRange range,
     MidBuiltinMethodDecl decl,
     IEnumerable<MidVal> args)
     : base(range, decl.ResultType)
 {
     _decl = decl;
     _args = args.ToArray();
 }
 public ResTypeParamDecl(
     SourceRange range,
     Identifier name,
     ResKind kind)
 {
     _range = range;
     _name = name;
     _kind = kind;
 }
 public MidElementCtorApp(
     SourceRange range,
     MidElementDecl element,
     IEnumerable<MidElementCtorArg> args)
     : base(range, new MidElementType(element))
 {
     _element = element;
     _args = args.ToArray();
 }
Exemple #20
0
        public CompilationError(SourceRange sourceRange, ErrorId id, string text)
        {
            if (text == null)
                throw ExceptionBuilder.ArgumentNull("text");

            _sourceRange = sourceRange;
            _id = id;
            _text = text;
        }
 public ResMethodApp(
     SourceRange range,
     IResTypeExp type,
     IResMethodRef method,
     IEnumerable<IResExp> args)
     : base(range, type)
 {
     _method = method;
     _args = args.ToArray();
 }
 public ResGlobalMemberTerm(
     SourceRange range,
     ILazy<IResModuleDecl> module,
     IResMemberDecl decl)
 {
     _range = range;
     _module = module;
     _decl = decl;
     _subst = new Substitution();
 }
 public ResAttributeFetch(
     SourceRange range,
     IResTypeExp type,
     IResExp obj,
     IResExp attribute)
     : base(range, type)
 {
     _obj = obj;
     _attribute = attribute;
 }
Exemple #24
0
 public ResIfExp(
     SourceRange range,
     IResExp condition,
     IResExp thenExp,
     IResExp elseExp)
     : base(range, thenExp.Type)
 {
     _condition = condition;
     _thenExp   = thenExp;
     _elseExp   = elseExp;
 }
Exemple #25
0
 public ResLetExp(
     SourceRange range,
     IResVarDecl var,
     IResExp value,
     IResExp body)
     : base(range, body.Type)
 {
     _var   = var;
     _value = value;
     _body  = body;
 }
Exemple #26
0
 public object Lookup(SourceRange range, IResGenericParamDecl key)
 {
     if (key is IResTypeParamDecl)
     {
         return(Lookup((IResTypeParamDecl)key));
     }
     else
     {
         return(Lookup(range, (IResVarDecl)key));
     }
 }
Exemple #27
0
 private static int Hash <T>(SourceRange range)
 {
     // The same json may resolve to two types. The cache key should include
     // type information.
     return(CombineHashCodes(
                new[]
     {
         range.GetHashCode(),
         typeof(T).GetHashCode()
     }));
 }
 private void RemoveArgumentSeparator(int argIndex)
 {
     if (!this.HasNoSeparatorLeftToRemove(base.Invocation.Arguments.Count, argIndex))
     {
         Expression  argument    = base.Argument(argIndex);
         Expression  nextArg     = base.NextArgument(argIndex);
         Expression  previousArg = base.PreviousArgument(argIndex);
         SourceRange range       = ExtraSourceCodeRangeToCleanup(argument, previousArg, nextArg);
         base.UpdateCollector.Remove(range, argument.LexicalInfo, null);
     }
 }
Exemple #29
0
 public ResFieldDecl(
     ILazy <IResMemberLineDecl> line,
     SourceRange range,
     Identifier name,
     ILazy <IResTypeExp> type,
     ILazy <IResExp> init)
     : base(line, range, name)
 {
     _type = type;
     _init = init;
 }
		void refactoringProvider_Apply(object sender, ApplyContentEventArgs ea)
		{
			var doc = CodeRush.Documents.ActiveTextDocument;
			var oldRefs = doc.GetNamespaceReferences();
			var oldRange = new SourceRange(oldRefs.First().Range.Start, 
										   oldRefs.Last().Range.End);

			var newRefs = SortReferencesByScope(oldRefs);
			var newCode = newRefs.OfType<LanguageElement>().GenerateCode();
			doc.Replace(oldRange, newCode, "Sorted Namespace References by Scope");
		}
Exemple #31
0
        public TypeSymbol(string name, SourceRange source, Type type)
        {
            if (type is UnresolvedType)
            {
                throw new System.ArgumentException($"Type is {nameof(UnresolvedType)}", nameof(type));
            }

            Name   = name;
            Source = source;
            Type   = type;
        }
Exemple #32
0
        protected SyntaxToken InsertMissingToken(SyntaxKind preferred, SyntaxKind[] otherOptions)
        {
            var missingTokenSourceRange = new SourceRange(Current.FullSourceRange.Start, 0);

            var diagnosticSpan = GetDiagnosticSourceRangeForMissingToken();
            var diagnostics    = new List <Diagnostic>(1);

            diagnostics.ReportTokenExpectedMultipleChoices(diagnosticSpan, Current, new[] { preferred }.Concat(otherOptions));

            return(SyntaxToken.CreateMissing(preferred, missingTokenSourceRange, GetSourceFileSpan(missingTokenSourceRange)).WithDiagnostics(diagnostics));
        }
Exemple #33
0
        protected SyntaxToken InsertMissingToken(SyntaxKind kind)
        {
            var missingTokenSourceRange = new SourceRange(Current.FullSourceRange.Start, 0);

            var diagnosticSpan = GetDiagnosticSourceRangeForMissingToken();
            var diagnostics    = new List <Diagnostic>(1);

            diagnostics.ReportTokenExpected(diagnosticSpan, Current, kind);

            return(SyntaxToken.CreateMissing(kind, missingTokenSourceRange, GetSourceFileSpan(missingTokenSourceRange)).WithDiagnostics(diagnostics));
        }
Exemple #34
0
 public ResForExp(
     SourceRange range,
     IResVarDecl var,
     IResExp sequence,
     IResExp body)
     : base(range, new ResVoidType())
 {
     _var      = var;
     _sequence = sequence;
     _body     = body;
 }
Exemple #35
0
 public ResConceptClassDecl(
     ILazy <IResMemberLineDecl> line,
     SourceRange range,
     Identifier name,
     ILazy <IResVarDecl> thisParameter,
     ILazy <IEnumerable <IResMemberNameGroup> > memberNameGroups)
     : base(line, range, name)
 {
     _thisParameter    = thisParameter;
     _memberNameGroups = memberNameGroups;
 }
Exemple #36
0
 public OpInfo(
     SourceRange range,
     D3D11_BLEND_OP op,
     AttrInfo left,
     AttrInfo right)
     : base(range)
 {
     _op    = op;
     _left  = left;
     _right = right;
 }
Exemple #37
0
 public MidPipelineDecl(
     IBuilder parent,
     Identifier name,
     MidEmitContext context,
     MidEmitEnv env,
     SourceRange range)
     : base(parent, context, env)
 {
     _name  = name;
     _range = range;
 }
Exemple #38
0
        private AttributeInfo DecomposeAttrImpl(
            SourceRange range,
            MidBuiltinApp midApp)
        {
            var name = midApp.Decl.GetTemplate("hlsl");
            var args = midApp.Args.ToArray();

            if (name == "__VertexFetch")
            {
                var buffer = args[0];
                var offset = args[1];
                var stride = args[2];
                var index  = args[3];

                var inputVertexStream = DecomposeVertexStream(buffer, offset, stride);
                var inputIndex        = DecomposeAttr(midApp.Range, index);

                return(GenerateInputElements(
                           midApp.Range,
                           "",
                           midApp.Type,
                           inputVertexStream,
                           inputIndex,
                           0));

                /*
                 * var inputSlotClass = "";
                 * var stepRate = 0;
                 *
                 * if (index is MidAttributeRef)
                 * {
                 *  var indexAttribRef = (MidAttributeRef)index;
                 *  if (indexAttribRef.Decl == _vertexID)
                 *  {
                 *      inputSlotClass = "D3D11_INPUT_PER_VERTEX_DATA";
                 *  }
                 *  else if (indexAttribRef.Decl == _instanceID)
                 *  {
                 *      inputSlotClass = "D3D11_INPUT_PER_INSTANCE_DATA";
                 *      stepRate = 1;
                 *  }
                 *
                 *  DecomposeInputElements(
                 *      span: span,
                 *      name: name,
                 *      type: exp.Type,
                 *      inputSlotIndex: inputSlotIndex,
                 *      inputSlotClass: inputSlotClass,
                 *      stepRate: stepRate);
                 * }*/
            }

            throw OperationTooComplex(midApp.Range);
        }
Exemple #39
0
 public MidLetExp(
     SourceRange range,
     MidVar var,
     MidExp exp,
     MidExp body)
     : base(range, new MidDummyType())
 {
     _var  = var;
     _exp  = exp;
     _body = body;
 }
 public ResVarDecl(
     SourceRange range,
     Identifier name,
     ILazy<IResTypeExp> type,
     ResVarFlags flags = ResVarFlags.None)
 {
     _range = range;
     _name = name;
     _type = type;
     _flags = flags;
 }
 public MidLetExp(
     SourceRange range,
     MidVar var,
     MidExp exp,
     MidExp body)
     : base(range, new MidDummyType())
 {
     _var = var;
     _exp = exp;
     _body = body;
 }
Exemple #42
0
        public static IResMemberRef App(
            this IResGenericRef fun,
            SourceRange range,
            IEnumerable <IResGenericArg> args)
        {
            var genericApp = new ResMemberGenericApp(
                fun,
                args);

            return(fun.InnerDecl.MakeRef(range, genericApp));
        }
 public MidAttributeFetch(
     SourceRange range,
     MidPath obj,
     MidAttributeDecl attribute,
     ILazyFactory lazyFactory )
     : base(range, new MidDummyType())
 {
     _obj = obj;
     _type = lazyFactory.New(() => _attribute.Value.Type);
     _attribute = Lazy.Value(attribute);
 }
 public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
     ISourceCode sourceCode,
     Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
     Violation violation,
     CsElement csElement)
 {
     var startPoint = csElement.ElementTokens.First().Location.StartPoint;
     var endPoint = csElement.ElementTokens.Last().Location.EndPoint;
     var sourceRange = new SourceRange(startPoint.LineNumber, startPoint.IndexOnLine + 1, endPoint.LineNumber, endPoint.IndexOnLine + 2);
     yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
 }
 public MidAttributeFetch(
     SourceRange range,
     MidPath obj,
     MidType type,
     ILazy<MidAttributeDecl> attribute)
     : base(range, new MidDummyType())
 {
     _obj = obj;
     _type = Lazy.Value(type);
     _attribute = attribute;
 }
        public IEnumerable <StyleCopCodeIssue> GetCodeIssues(
            ISourceCode sourceCode,
            Func <ElementTypeFilter, IEnumerable <IElement> > enumerate,
            Violation violation,
            CsElement csElement)
        {
            var startPoint  = csElement.ElementTokens.First().Location.StartPoint;
            var endPoint    = csElement.ElementTokens.Last().Location.EndPoint;
            var sourceRange = new SourceRange(startPoint.LineNumber, startPoint.IndexOnLine + 1, endPoint.LineNumber, endPoint.IndexOnLine + 2);

            yield return(new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange));
        }
        public SymbolSpan(SymbolSpanKind kind, Symbol symbol, SourceRange sourceRange, TextSpan span)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            Kind        = kind;
            Symbol      = symbol;
            SourceRange = sourceRange;
            Span        = span;
        }
 protected void RegisterChildNodes <T>(out SeparatedSyntaxList <T> nodes, SeparatedSyntaxList <T> values)
     where T : SyntaxNodeBase
 {
     nodes = values;
     foreach (var childNode in values.GetWithSeparators())
     {
         SourceRange     = SourceRange.Union(SourceRange, childNode.SourceRange);
         FullSourceRange = SourceRange.Union(FullSourceRange, childNode.FullSourceRange);
         ChildNodes.Add(childNode);
         childNode.Parent = this;
     }
 }
Exemple #49
0
        IResMemberRef IResContainerBuilderRef.CreateMemberRef(SourceRange range, IResMemberDecl memberDecl)
        {
            var resGesGenericDecl = _genericDeclBuilder.Value;
            var resGenericRef     = (IResGenericRef)_outerContainerBuilder.CreateMemberRef(range, resGesGenericDecl);

            return(memberDecl.MakeRef(
                       range,
                       new ResMemberGenericApp(
                           resGenericRef,
                           (from p in resGenericRef.Parameters
                            select p.MakeArg(range)).ToArray())));
        }
Exemple #50
0
        private AttributeInfo DecomposeAttrImpl(
            SourceRange range,
            MidFieldRef midFieldRef)
        {
            var structAttrInfo = (StructInfo)DecomposeAttr(midFieldRef.Range, midFieldRef.Obj);

            var fieldInfo = (from f in structAttrInfo.Fields
                             where f.Field == midFieldRef.Decl
                             select f.Info).First();

            return(fieldInfo);
        }
Exemple #51
0
        public void TestRangeContains()
        {
            var a = new SourceLocation(1, 15);
            var b = new SourceLocation(2, 10);
            var c = new SourceLocation(5, 10);

            var r  = new SourceRange("test.sc", (1, 0), (3, 20));
            var r1 = new SourceRange("test.sc", (1, 10), (2, 10));
            var r2 = new SourceRange("test.sc", (4, 0), (5, 10));

            Assert.True(r.Contains(r.Start));
            Assert.True(r.Contains(r.End));

            Assert.True(r.Contains(a));
            Assert.True(r.Contains(b));
            Assert.False(r.Contains(c));

            Assert.True(r.Contains(r));
            Assert.True(r.Contains(r1));
            Assert.False(r.Contains(r2));
        }
Exemple #52
0
        void refactoringProvider_Apply(object sender, ApplyContentEventArgs ea)
        {
            var doc      = CodeRush.Documents.ActiveTextDocument;
            var oldRefs  = doc.GetNamespaceReferences();
            var oldRange = new SourceRange(oldRefs.First().Range.Start,
                                           oldRefs.Last().Range.End);

            var newRefs = SortReferencesByScope(oldRefs);
            var newCode = newRefs.OfType <LanguageElement>().GenerateCode();

            doc.Replace(oldRange, newCode, "Sorted Namespace References by Scope");
        }
        public ResMemberSpec(
            SourceRange range,
            IResContainerRef container,
            IResMemberDecl decl)
        {
            if (decl == null)
                throw new ArgumentNullException("decl");

            _range = range;
            _container = container;
            _decl = decl;
        }
Exemple #54
0
        public IEnumerable <IResMemberNameGroupSpec> LookupMembers(SourceRange range, Identifier name)
        {
            var nameGroup = Decl.LookupMemberNameGroup(name);

            if (nameGroup != null)
            {
                yield return(new ResMemberNameGroupSpec(
                                 range,
                                 this,
                                 nameGroup));
            }
        }
Exemple #55
0
        public void EmitNonCodeLineInfo(SourceRange range)
        {
            if (_outputEnabled && _emitDebugInfo)
            {
                EmitDeferredInstructions();
                _emitter.EmitLineInfo(range, _methodFileName ?? string.Empty);
                _emitter.NoOp();

                _isSourceLine   = false;
                _methodFileName = null; // We only need to emit this for the first line
            }
        }
        public void GetStartAndGetEndReturnOriginalLocations()
        {
            var add = disposables.Add;

            var file  = add.GetFile(TestFiles.AddSource);
            var begin = file.GetLocation(1, 1);
            var end   = file.GetLocation(2, 1);
            var range = SourceRange.Create(begin, end);

            Assert.AreEqual(begin, range.GetStart());
            Assert.AreEqual(end, range.GetEnd());
        }
Exemple #57
0
 private AttributeInfo TryDecomposeAttr(
     SourceRange range,
     MidAttributeDecl midAttrDecl)
 {
     try
     {
         return(DecomposeAttr(range, midAttrDecl));
     }
     catch (D3D11InputAssemblerOperationTooComplex)
     {
         return(null);
     }
 }
Exemple #58
0
 internal LiteralNode UninterpretedTokenToLNode(ISourceFile file, object value)
 {
     if (SubstringOffset == 0xFF)
     {
         var lv = new LiteralValue(value, TypeMarker, TextValue(file.Text));
         return(new StdLiteralNode <LiteralValue>(lv, SourceRange.New(file, this), Style));
     }
     else
     {
         var lfp = new LiteralFromParser(value, _startIndex + SubstringOffset, _length - SubstringOffset - SubstringOffsetFromEnd, TypeMarker);
         return(new StdLiteralNode <LiteralFromParser>(lfp, SourceRange.New(file, this), Style));
     }
 }
Exemple #59
0
 public ResAttributeDecl(
     ILazy <IResMemberLineDecl> line,
     SourceRange range,
     Identifier name,
     ILazy <IResFreqQualType> type,
     ILazy <IResExp> init,
     ILazy <ResAttributeFlags> flags)
     : base(line, range, name)
 {
     _type  = type;
     _init  = init;
     _flags = flags;
 }
Exemple #60
0
        private D3D11InputAssemblerOperationTooComplex OperationTooComplex(SourceRange range)
        {
            Diagnostics.Add(
                Severity.Error,
                range,
                "This operation is too complex for the D3D11 Input Assembler (IA) stage");
            Diagnostics.Add(
                Severity.Info,
                range,
                "Consider using the @CoarseVertex rate to map computations to the Vertex Shader (VS)");

            return(new D3D11InputAssemblerOperationTooComplex());
        }