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


C# ITextProvider.GetText方法代码示例

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


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

示例1: IsSelfClosing

        /// <summary>
        /// Determines if element is a self-closing element (i.e. like &lt;br /&gt;
        /// </summary>
        /// <param name="textProvider">Text provider</param>
        /// <param name="prefixRange">Text range of the element prefix</param>
        /// <param name="nameRange">Text range of the element name</param>
        /// <returns>True if element is a self-closing element.</returns>
        public bool IsSelfClosing(ITextProvider textProvider, ITextRange prefixRange, ITextRange nameRange) {
            if (nameRange.Length == 0)
                return false;

            string name = textProvider.GetText(nameRange);
            if (name[0] == '!')
                return true; // bang tags are always self-closing

            if (prefixRange.Length == 0)
                return _defaultProvider.IsSelfClosing(textProvider, nameRange);

            string prefix = textProvider.GetText(prefixRange);

            IHtmlClosureProvider provider; ;
            _providers.TryGetValue(prefix, out provider);

            var textRangeProvider = provider as IHtmlClosureProviderTextRange;
            if (textRangeProvider != null)
                return textRangeProvider.IsSelfClosing(textProvider, nameRange);

            if (provider != null)
                return provider.IsSelfClosing(name);

            return false;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:32,代码来源:ElementClosureProvider.cs

示例2: GetName

        public string GetName(ITextProvider text)
        {
            if (IsValid)
                return text.GetText(Name.Start, Name.Length);

            return null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:7,代码来源:UserFunctionDefinition.cs

示例3: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsModifier(text.GetText(stream.Current.Start, stream.Current.Length)))
                Modifier = Children.AddCurrentAndAdvance(stream);

            ParseItem mediaType;
            if (itemFactory.TryCreateParsedOrDefault(this, text, stream, out mediaType))
            {
                MediaType = mediaType;
                Children.Add(mediaType);
            }

            while (!IsTerminator(text, stream))
            {
                var expression = itemFactory.CreateSpecific<MediaQueryExpression>(this, text, stream);
                if (expression.Parse(itemFactory, text, stream))
                {
                    _Expressions.Add(expression);
                    Children.Add(expression);
                }
                else
                {
                    Children.AddCurrentAndAdvance(stream);
                }
            }

            if (stream.Current.Type == TokenType.Comma)
                Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:31,代码来源:MediaQuery.cs

示例4: ResolvePath

        public static string ResolvePath(StringValue item, ITextProvider text, DirectoryInfo currentDirectory)
        {
            var relativePath = text.GetText(item.Start, item.Length).Trim('\'', '"');
            var segments = relativePath.Split('/');
            if (segments.Length == 0)
                return null;

            var path = currentDirectory.FullName;
            for (int i = 0; i < (segments.Length - 1); i++)
                path = Path.Combine(path, segments[i]);

            var directory = new DirectoryInfo(Path.GetFullPath(path));
            if (!directory.Exists)
                return null;

            var filename = segments[segments.Length - 1];
            if (string.IsNullOrEmpty(Path.GetExtension(filename)))
                filename += ".scss";

            var files = directory.GetFiles("*" + filename);

            var comparer = StringComparer.OrdinalIgnoreCase;
            return files.Where(x => comparer.Equals(x.Name, filename) || comparer.Equals(x.Name, "_" + filename))
                .Select(x => x.FullName)
                .FirstOrDefault();
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:26,代码来源:ImportResolver.cs

示例5: GetName

        public string GetName(ITextProvider text)
        {
            if (Fragments.Count == 0 || !Fragments.All(x => x is TokenItem))
                return "";

            var start = Fragments[0];
            var end = Fragments[Fragments.Count - 1];

            return text.GetText(start.Start, end.End - start.Start);
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:10,代码来源:PropertyName.cs

示例6: IsRule

        public static bool IsRule(ITextProvider text, ITokenStream stream, string name)
        {
            if (stream.Current.Type == TokenType.At)
            {
                var nameToken = stream.Peek(1);
                if (nameToken.Type == TokenType.Identifier)
                    return text.GetText(nameToken.Start, name.Length) == name;
            }

            return false;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:11,代码来源:AtRule.cs

示例7: Add

        public override void Add(ParseItem item, ITextProvider text)
        {
            if (item is SassImportDirective)
            {
                var directive = item as SassImportDirective;
                foreach (var file in directive.Files.Where(x => x.IsValid))
                    Containers.Add(new ImportContainer(directive, IntellisenseManager.Get(file.Document)));
            }
            else if (item is XmlDocumentationComment)
            {
                var comment = item as XmlDocumentationComment;
                foreach (var tag in comment.Children.OfType<FileReferenceTag>().Where(x => x.Document != null))
                    Containers.Add(new ImportContainer(tag, IntellisenseManager.Get(tag.Document)));
            }
            else if (item is MixinDefinition)
            {
                var definition = item as MixinDefinition;
                if (definition.Name != null && definition.Name.Name != null)
                {
                    Parse(new MixinContainer(definition, text), definition.Children, text);

                    var name = text.GetText(definition.Name.Name.Start, definition.Name.Name.Length);
                    _Mixins.Add(definition.End, new MixinCompletionValue(name));
                }
            }
            else if (item is UserFunctionDefinition)
            {
                var definition = item as UserFunctionDefinition;
                if (definition.Name != null)
                {
                    Parse(new FunctionContainer(definition, text), definition.Children, text);

                    var name = text.GetText(definition.Name.Start, definition.Name.Length);
                    _Functions.Add(definition.End, new UserFunctionCompletionValue(name));
                }
            }
            else
            {
                base.Add(item, text);
            }
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:41,代码来源:StylesheetContainer.cs

示例8: CreateDocumentationTag

        static ParseItem CreateDocumentationTag(ComplexItem parent, IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (!(parent is XmlDocumentationComment))
                return null;

            if (stream.Current.Type == TokenType.LessThan)
            {
                var next = stream.Peek(1);
                if (next.Type != TokenType.Identifier)
                    return null;

                switch (text.GetText(next.Start, next.Length))
                {
                    case "reference": return new FileReferenceTag();
                }
            }

            return null;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:19,代码来源:DefaultSassItemFactory.cs

示例9: AddVariable

        protected void AddVariable(VariableDefinition variable, ITextProvider text)
        {
            if (variable != null && variable.IsValid)
            {
                var variableName = variable.Name;
                var builder = new StringBuilder(variableName.Length);
                builder.Append(variableName.Prefix.SourceType == TokenType.Dollar ? '$' : '!');
                builder.Append(text.GetText(variableName.Name.Start, variableName.Name.Length));

                var name = builder.ToString();
                _Variables.Add(variable.Start, new VariableCompletionValue
                {
                    DisplayText = name,
                    CompletionText = name,
                    Start = variableName.Start,
                    End = variableName.End,
                    Length = variableName.Length
                });
            }
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:20,代码来源:CompletionContainerBase.cs

示例10: Parse

        public override bool Parse(IItemFactory itemFactory, ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Identifier && IsValidNamedRange(text.GetText(stream.Current.Start, stream.Current.Length)))
            {
                AnimationBegin = Children.AddCurrentAndAdvance(stream, SassClassifierType.Keyword);
            }
            else if (stream.Current.Type == TokenType.Number && stream.Peek(1).Type == TokenType.PercentSign)
            {
                ParseItem begin = itemFactory.Create<PercentageUnit>(this, text, stream);
                if (begin.Parse(itemFactory, text, stream))
                {
                    AnimationBegin = begin;
                    Children.Add(begin);

                    if (stream.Current.Type == TokenType.Comma)
                        Comma = Children.AddCurrentAndAdvance(stream, SassClassifierType.Punctuation);

                    ParseItem end = itemFactory.Create<PercentageUnit>(this, text, stream);
                    if (end.Parse(itemFactory, text, stream))
                    {
                        AnimationEnd = end;
                        Children.Add(end);
                    }
                }
            }

            if (AnimationBegin != null)
            {
                var block = itemFactory.CreateSpecific<RuleBlock>(this, text, stream);
                if (block.Parse(itemFactory, text, stream))
                {
                    Body = block;
                    Children.Add(block);
                }
            }

            return Children.Count > 0;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:38,代码来源:KeyframeSelector.cs

示例11: CheckRange

 private static bool CheckRange(int surroundingLength, Func<string, bool> predicate, int rangeStart, int rangeLength, ITextProvider rangeText)
 {
     if (rangeLength == 0)
         return false;
     var surroundingText = rangeText.GetText(new Microsoft.Web.Core.Text.TextRange(
         rangeStart,
         Math.Min(rangeText.Length - rangeStart, rangeLength + surroundingLength)
     ));
     return predicate(surroundingText);
 }
开发者ID:irongiant,项目名称:WebEssentials2015,代码行数:10,代码来源:CodeArtifactProcessor.cs

示例12: ApplyChangeByTokens

        /// <summary>
        /// Incrementally applies whitespace change to the buffer 
        /// having old and new tokens produced from the 'before formatting' 
        /// and 'after formatting' versions of the same text.
        /// </summary>
        /// <param name="textBuffer">Text buffer to apply changes to</param>
        /// <param name="newTextProvider">Text provider of the text fragment before formatting</param>
        /// <param name="newTextProvider">Text provider of the formatted text</param>
        /// <param name="oldTokens">Tokens from the 'before' text fragment</param>
        /// <param name="newTokens">Tokens from the 'after' text fragment</param>
        /// <param name="formatRange">Range that is being formatted in the text buffer</param>
        /// <param name="transactionName">Name of the undo transaction to open</param>
        /// <param name="selectionTracker">Selection tracker object that will save, track
        /// <param name="additionalAction">Action to perform after changes are applies by undo unit is not yet closed.</param>
        /// and restore selection after changes have been applied.</param>
        public static void ApplyChangeByTokens(
            ITextBuffer textBuffer,
            ITextProvider oldTextProvider,
            ITextProvider newTextProvider,
            IReadOnlyList<ITextRange> oldTokens,
            IReadOnlyList<ITextRange> newTokens,
            ITextRange formatRange,
            string transactionName,
            ISelectionTracker selectionTracker,
            IEditorShell editorShell,
            Action additionalAction = null) {

            Debug.Assert(oldTokens.Count == newTokens.Count);
            if (oldTokens.Count == newTokens.Count) {
                ITextSnapshot snapshot = textBuffer.CurrentSnapshot;
                using (CreateSelectionUndo(selectionTracker, editorShell, transactionName)) {
                    using (ITextEdit edit = textBuffer.CreateEdit()) {
                        if (oldTokens.Count > 0) {
                            // Replace whitespace between tokens in reverse so relative positions match
                            int oldEnd = oldTextProvider.Length;
                            int newEnd = newTextProvider.Length;
                            string oldText, newText;
                            for (int i = newTokens.Count - 1; i >= 0; i--) {
                                oldText = oldTextProvider.GetText(TextRange.FromBounds(oldTokens[i].End, oldEnd));
                                newText = newTextProvider.GetText(TextRange.FromBounds(newTokens[i].End, newEnd));
                                if (oldText != newText) {
                                    edit.Replace(formatRange.Start + oldTokens[i].End, oldEnd - oldTokens[i].End, newText);
                                }
                                oldEnd = oldTokens[i].Start;
                                newEnd = newTokens[i].Start;
                            }
                            newText = newTextProvider.GetText(TextRange.FromBounds(0, newEnd));
                            edit.Replace(formatRange.Start, oldEnd, newText);
                        } else {
                            string newText = newTextProvider.GetText(TextRange.FromBounds(0, newTextProvider.Length));
                            edit.Replace(formatRange.Start, formatRange.Length, newText);
                        }
                        edit.Apply();
                        additionalAction?.Invoke();
                    }
                }
            }
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:58,代码来源:IncrementalChangeApplication.cs

示例13: IsImplicitlyClosed

        /// <summary>
        /// Determines if given element can be implicitly closed like &lt;li&gt; or &lt;td&gt; in HTML"
        /// </summary>
        /// <param name="text">Text provider</param>
        /// <param name="name">Element name</param>
        /// <returns>True if element can be implictly closed</returns>
        public bool IsImplicitlyClosed(ITextProvider text, ITextRange name, out string[] containerElementNames) {
            containerElementNames = null;

            if (name.Length < _minCharCountImplicitClosing || name.Length > _maxCharCountImplicitClosing)
                return false;

            bool found = FindElementName(text, name, _implicitlyClosingElementNameIndex, ignoreCase: true);
            if (found) {
                string elementName = text.GetText(name);
                containerElementNames = GetContainerElements(elementName);
            }
            return found;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:19,代码来源:DefaultClosureProvider.cs

示例14: IsDestructiveChangeForSeparator

        private bool IsDestructiveChangeForSeparator(
            ISensitiveFragmentSeparatorsInfo separatorInfo,
            IEnumerable<IArtifact> itemsInRange,
            int start,
            int oldLength,
            int newLength,
            ITextProvider oldText,
            ITextProvider newText
        ) {
            if (separatorInfo == null || (separatorInfo.LeftSeparator.Length == 0 && separatorInfo.RightSeparator.Length == 0)) {
                return false;
            }

            // Find out if one of the existing fragments contains position 
            // and if change damages fragment start or end separators

            string leftSeparator = separatorInfo.LeftSeparator;
            string rightSeparator = separatorInfo.RightSeparator;

            var firstTwoItems = itemsInRange.Take(2).ToList();
            var item = firstTwoItems.FirstOrDefault();

            // If no items are affected, change is unsafe only if new region contains left side separators.
            if (item == null) {
                // Simple optimization for whitespace insertion
                if (oldLength == 0 && string.IsNullOrWhiteSpace(newText.GetText(new TextRange(start, newLength)))) {
                    return false;
                }

                // Take into account that user could have deleted space between existing 
                // { and % or added { to the existing % so extend search range accordingly.
                int fragmentStart = Math.Max(0, start - leftSeparator.Length + 1);
                int fragmentEnd = Math.Min(newText.Length, start + newLength + leftSeparator.Length - 1);
                return newText.IndexOf(leftSeparator, TextRange.FromBounds(fragmentStart, fragmentEnd), true) >= 0;
            }

            // Is change completely inside an existing item?
            if (firstTwoItems.Count == 1 && (item.Contains(start) && item.Contains(start + oldLength))) {
                // Check that change does not affect item left separator
                if (TextRange.Contains(item.Start, leftSeparator.Length, start)) {
                    return true;
                }

                // Check that change does not affect item right separator. Note that we should not be using 
                // TextRange.Intersect since in case oldLength is zero (like when user is typing right before %} or }})
                // TextRange.Intersect will determine that zero-length range intersects with the right separator
                // which is incorrect. Typing at position 10 does not change separator at position 10. Similarly,
                // deleting text right before %} or }} does not make change destructive.

                var htmlToken = item as IHtmlToken;
                if (htmlToken == null || htmlToken.IsWellFormed) {
                    int rightSeparatorStart = item.End - rightSeparator.Length;
                    if (start + oldLength > rightSeparatorStart) {
                        if (TextRange.Intersect(rightSeparatorStart, rightSeparator.Length, start, oldLength)) {
                            return true;
                        }
                    }
                }

                // Touching left separator is destructive too, like when changing {{ to {{@
                // Check that change does not affect item left separator (whitespace is fine)
                if (item.Start + leftSeparator.Length == start) {
                    if (oldLength == 0) {
                        string text = newText.GetText(new TextRange(start, newLength));
                        if (String.IsNullOrWhiteSpace(text)) {
                            return false;
                        }
                    }

                    return true;
                }

                int fragmentStart = item.Start + separatorInfo.LeftSeparator.Length;
                fragmentStart = Math.Max(fragmentStart, start - separatorInfo.RightSeparator.Length + 1);
                int changeLength = newLength - oldLength;
                int fragmentEnd = item.End + changeLength;
                fragmentEnd = Math.Min(fragmentEnd, start + newLength + separatorInfo.RightSeparator.Length - 1);

                if (newText.IndexOf(separatorInfo.RightSeparator, TextRange.FromBounds(fragmentStart, fragmentEnd), true) >= 0) {
                    return true;
                }

                return false;
            }

            return true;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:87,代码来源:TemplateArtifactCollection.cs

示例15: IsWellKnownFunction

        public static bool IsWellKnownFunction(ITextProvider text, ITokenStream stream)
        {
            if (stream.Current.Type == TokenType.Function || stream.Current.Type == TokenType.Identifier)
            {
                var functionName = text.GetText(stream.Current.Start, stream.Current.Length);
                return WellKnownFunctions.Contains(functionName);
            }

            return false;
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:10,代码来源:Function.cs


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