Example #1
0
        /// <summary>
        /// For given result item with specified ReplaceSpan calculates AbsoluteCharOffset and AbsoluteCharLength
        /// </summary>
        protected static void CalculateAbsolutePosition(AbstractResultItem item)
        {
            IVsTextLines view = VLDocumentViewsManager.GetTextLinesForFile(item.SourceItem.GetFullPath(), true);
            object       o;

            view.CreateTextPoint(item.ReplaceSpan.iStartLine, item.ReplaceSpan.iStartIndex, out o);
            TextPoint tp = (TextPoint)o;

            item.AbsoluteCharOffset = tp.AbsoluteCharOffset + item.ReplaceSpan.iStartLine - 1;

            view.CreateTextPoint(item.ReplaceSpan.iEndLine, item.ReplaceSpan.iEndIndex, out o);
            TextPoint tp2 = (TextPoint)o;

            item.AbsoluteCharLength = tp2.AbsoluteCharOffset + item.ReplaceSpan.iEndLine - 1 - item.AbsoluteCharOffset;
        }
Example #2
0
        /// <summary>
        /// Returns true if given result item lies outside the selection
        /// </summary>
        protected bool IsItemOutsideSelection(AbstractResultItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (selectionBotPoint == null)
            {
                throw new ArgumentNullException("selectionBotPoint");
            }
            if (selectionTopPoint == null)
            {
                throw new ArgumentNullException("selectionTopPoint");
            }

            int startOffset = item.AbsoluteCharOffset - item.ReplaceSpan.iStartLine + 2;
            int endOffset   = item.AbsoluteCharOffset + item.AbsoluteCharLength - item.ReplaceSpan.iEndLine + 2;

            int bottom = Math.Max(selectionBotPoint.AbsoluteCharOffset, selectionTopPoint.AbsoluteCharOffset);
            int top    = Math.Min(selectionBotPoint.AbsoluteCharOffset, selectionTopPoint.AbsoluteCharOffset);

            return((startOffset > bottom) || (endOffset <= top));
        }
Example #3
0
        /// <summary>
        /// Compares expected and actual result item
        /// </summary>
        internal static void ValidateItems(AbstractResultItem a, AbstractResultItem b)
        {
            if (b is NetStringResultItem)
            {
                NetStringResultItem an = a as NetStringResultItem;
                NetStringResultItem bn = b as NetStringResultItem;
                Assert.AreEqual(an.VariableElementName, bn.VariableElementName, "Variable names are not equal, " + a.Value);
                Assert.AreEqual(an.MethodElementName, bn.MethodElementName, "Method names are not equal, " + a.Value);
            }
            if (b is CSharpStringResultItem)
            {
                TestCSharpStringResultItem an = a as TestCSharpStringResultItem;
                CSharpStringResultItem     bn = b as CSharpStringResultItem;
                if (an.NamespaceElementName == null)
                {
                    Assert.IsNull(bn.NamespaceElement, "Namespace null, " + a.Value);
                }
                else
                {
                    Assert.AreEqual(an.NamespaceElementName, bn.NamespaceElement.FullName, "Namespace names are not equal, " + a.Value);
                }
            }
            if (b is VBStringResultItem)
            {
                TestVBStringResultItem an = a as TestVBStringResultItem;
                VBStringResultItem     bn = b as VBStringResultItem;
                if (an.NamespaceElementName == null)
                {
                    Assert.IsNull(bn.NamespaceElement, "Namespace null, " + a.Value);
                }
                else
                {
                    Assert.AreEqual(an.NamespaceElementName, bn.NamespaceElement.FullName, "Namespace names are not equal, " + a.Value);
                }
            }
            if (b is AspNetStringResultItem)
            {
                TestAspNetStringResultItem an = a as TestAspNetStringResultItem;
                AspNetStringResultItem     bn = b as AspNetStringResultItem;

                Assert.AreEqual(an.ComesFromClientComment, bn.ComesFromClientComment, "ComesFromClientComment are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ComesFromCodeBlock, bn.ComesFromCodeBlock, "ComesFromCodeBlock are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ComesFromDirective, bn.ComesFromDirective, "ComesFromDirective are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ComesFromElement, bn.ComesFromElement, "ComesFromElement are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ComesFromInlineExpression, bn.ComesFromInlineExpression, "ComesFromInlineExpression are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ComesFromPlainText, bn.ComesFromPlainText, "ComesFromPlainText are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ElementName, bn.ElementName, "ElementName are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ElementPrefix, bn.ElementPrefix, "ElementPrefix are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.LocalizabilityProved, bn.LocalizabilityProved, "LocalizabilityProved are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.Language, bn.Language, "Language are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            }
            if (b is CodeStringResultItem)
            {
                CodeStringResultItem an = a as CodeStringResultItem;
                CodeStringResultItem bn = b as CodeStringResultItem;
                Assert.AreEqual(an.WasVerbatim, bn.WasVerbatim, "Verbatim options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ClassOrStructElementName, bn.ClassOrStructElementName, "Class names are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            }


            if (b is CodeReferenceResultItem)
            {
                CodeReferenceResultItem an = a as CodeReferenceResultItem;
                CodeReferenceResultItem bn = b as CodeReferenceResultItem;

                Assert.AreEqual(an.FullReferenceText, bn.FullReferenceText, "FullReferenceText are not equal" + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.OriginalReferenceText, bn.OriginalReferenceText, "OriginalReferenceText are not equal" + " on line " + a.ReplaceSpan.iStartLine);
            }
            if (b is AspNetCodeReferenceResultItem)
            {
                AspNetCodeReferenceResultItem an = a as AspNetCodeReferenceResultItem;
                AspNetCodeReferenceResultItem bn = b as AspNetCodeReferenceResultItem;

                Assert.AreEqual(an.ComesFromInlineExpression, bn.ComesFromInlineExpression, "ComesFromInlineExpression are not equal" + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.ComesFromWebSiteResourceReference, bn.ComesFromWebSiteResourceReference, "ComesFromWebSiteResourceReference are not equal" + " on line " + a.ReplaceSpan.iStartLine);
                Assert.AreEqual(an.Language, bn.Language, "Language are not equal" + " on line " + a.ReplaceSpan.iStartLine);

                if (an.ComesFromInlineExpression)
                {
                    Assert.IsNotNull(an.InlineReplaceSpan);
                    Assert.IsNotNull(bn.InlineReplaceSpan);
                    Assert.AreEqual(an.InlineReplaceSpan.StartLine, bn.InlineReplaceSpan.StartLine, "StartLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                    Assert.AreEqual(an.InlineReplaceSpan.StartIndex, bn.InlineReplaceSpan.StartIndex, "StartIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                    Assert.AreEqual(an.InlineReplaceSpan.EndLine, bn.InlineReplaceSpan.EndLine, "EndLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                    Assert.AreEqual(an.InlineReplaceSpan.EndIndex, bn.InlineReplaceSpan.EndIndex, "EndIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);

                    Assert.AreEqual(an.InlineReplaceSpan.AbsoluteCharOffset, bn.InlineReplaceSpan.AbsoluteCharOffset, "Offsets are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                    Assert.AreEqual(an.InlineReplaceSpan.AbsoluteCharLength, bn.InlineReplaceSpan.AbsoluteCharLength, "AbsoluteLengths are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
                }
                else
                {
                    Assert.IsNull(an.InlineReplaceSpan);
                    Assert.IsNull(bn.InlineReplaceSpan);
                }
            }

            Assert.AreEqual(a.Value, b.Value, "Values are not equal on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.SourceItem, b.SourceItem, "Source items are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.IsWithinLocalizableFalse, b.IsWithinLocalizableFalse, "[Localizable(false)] options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.IsMarkedWithUnlocalizableComment, b.IsMarkedWithUnlocalizableComment, "/*VL_NO_LOC*/ options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.ComesFromDesignerFile, b.ComesFromDesignerFile, "Designer file options are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);

            Assert.IsNotNull(a.ReplaceSpan);
            Assert.IsNotNull(b.ReplaceSpan);
            Assert.AreEqual(a.ReplaceSpan.iStartLine, b.ReplaceSpan.iStartLine, "iStartLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.ReplaceSpan.iStartIndex, b.ReplaceSpan.iStartIndex, "iStartIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.ReplaceSpan.iEndLine, b.ReplaceSpan.iEndLine, "iEndLine are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.ReplaceSpan.iEndIndex, b.ReplaceSpan.iEndIndex, "iEndIndex are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);

            Assert.AreEqual(a.AbsoluteCharOffset, b.AbsoluteCharOffset, "Offsets are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);
            Assert.AreEqual(a.AbsoluteCharLength, b.AbsoluteCharLength, "AbsoluteLengths are not equal, " + a.Value + " on line " + a.ReplaceSpan.iStartLine);

            Assert.AreEqual(a.IsConst, b.IsConst, "IsConst are not equal on line " + a.ReplaceSpan.iStartLine);
        }