• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ITextSnapshot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITextSnapshot的典型用法代码示例。如果您正苦于以下问题:C# ITextSnapshot类的具体用法?C# ITextSnapshot怎么用?C# ITextSnapshot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITextSnapshot类属于命名空间,在下文中一共展示了ITextSnapshot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ParseSnapshot

        internal static AntlrParseResultEventArgs ParseSnapshot(ITextSnapshot snapshot)
        {
            Stopwatch timer = Stopwatch.StartNew();

            ITokenSource tokenSource = new GrammarLexer(new AntlrInputStream(snapshot.GetText()));
            CommonTokenStream tokenStream = new CommonTokenStream(tokenSource);
            GrammarParser.GrammarSpecContext parseResult;
            GrammarParser parser = new GrammarParser(tokenStream);
            List<ParseErrorEventArgs> errors = new List<ParseErrorEventArgs>();
            try
            {
                parser.Interpreter.PredictionMode = PredictionMode.Sll;
                parser.RemoveErrorListeners();
                parser.BuildParseTree = true;
                parser.ErrorHandler = new BailErrorStrategy();
                parseResult = parser.grammarSpec();
            }
            catch (ParseCanceledException ex)
            {
                if (!(ex.InnerException is RecognitionException))
                    throw;

                tokenStream.Reset();
                parser.Interpreter.PredictionMode = PredictionMode.Ll;
                //parser.AddErrorListener(DescriptiveErrorListener.Default);
                parser.SetInputStream(tokenStream);
                parser.ErrorHandler = new DefaultErrorStrategy();
                parseResult = parser.grammarSpec();
            }

            return new AntlrParseResultEventArgs(snapshot, errors, timer.Elapsed, tokenStream.GetTokens(), parseResult);
        }
开发者ID:chandramouleswaran,项目名称:LangSvcV2,代码行数:32,代码来源:Antlr4BackgroundParser.cs


示例2: InsertEmbedString

        private void InsertEmbedString(ITextSnapshot snapshot, string dataUri)
        {
            using (EditorExtensionsPackage.UndoContext((DisplayText)))
            {
                Declaration dec = _url.FindType<Declaration>();

                if (dec != null && dec.Parent != null && !(dec.Parent.Parent is FontFaceDirective)) // No declaration in LESS variable definitions
                {
                    RuleBlock rule = _url.FindType<RuleBlock>();
                    string text = dec.Text;

                    if (dec != null && rule != null)
                    {
                        Declaration match = rule.Declarations.FirstOrDefault(d => d.PropertyName != null && d.PropertyName.Text == "*" + dec.PropertyName.Text);
                        if (!text.StartsWith("*", StringComparison.Ordinal) && match == null)
                            _span.TextBuffer.Insert(dec.AfterEnd, "*" + text + "/* For IE 6 and 7 */");
                    }
                }

                _span.TextBuffer.Replace(_span.GetSpan(snapshot), dataUri);

                EditorExtensionsPackage.ExecuteCommand("Edit.FormatSelection");
                EditorExtensionsPackage.ExecuteCommand("Edit.CollapsetoDefinitions");
            }
        }
开发者ID:Gordon-Beeming,项目名称:WebEssentials2013,代码行数:25,代码来源:EmbedSmartTagAction.cs


示例3: FullParse

        private GherkinFileScopeChange FullParse(ITextSnapshot textSnapshot, GherkinDialect gherkinDialect)
        {
            visualStudioTracer.Trace("Start full parsing", ParserTraceCategory);
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            partialParseCount = 0;

            var gherkinListener = new GherkinTextBufferParserListener(gherkinDialect, textSnapshot, projectScope.Classifications);

            var scanner = new GherkinScanner(gherkinDialect, textSnapshot.GetText(), 0);
            scanner.Scan(gherkinListener);

            var gherkinFileScope = gherkinListener.GetResult();

            var result = new GherkinFileScopeChange(
                gherkinFileScope,
                true, true,
                gherkinFileScope.GetAllBlocks(),
                Enumerable.Empty<IGherkinFileBlock>());

            stopwatch.Stop();
            TraceFinishParse(stopwatch, "full", result);

            return result;
        }
开发者ID:eddpeterson,项目名称:SpecFlow,代码行数:26,代码来源:GherkinTextBufferParser.cs


示例4: GetMarkerLinesForFile

        public List<MarkerLine> GetMarkerLinesForFile(ITextSnapshot textSnapshot)
        {
            var lines = new List<MarkerLine>();

            if (_threadFixPlugin == null || _threadFixPlugin.MarkerLookUp == null)
            {
                return lines;
            }

            var filename = textSnapshot.TextBuffer.GetTextDocument().FilePath.ToLower();
            var markers = new List<VulnerabilityMarker>();

            if(_threadFixPlugin.MarkerLookUp.TryGetValue(filename, out markers) && !string.IsNullOrEmpty(filename))
            {
                foreach (var marker in markers)
                {
                    if (marker.LineNumber.HasValue && marker.LineNumber.Value > 0 && marker.LineNumber.Value < textSnapshot.LineCount)
                    {
                        lines.Add(new MarkerLine(textSnapshot.GetLineFromLineNumber(marker.LineNumber.Value - 1), marker.GenericVulnName));
                    }
                }
            }

            return lines;
        }
开发者ID:yehgdotnet,项目名称:threadfix,代码行数:25,代码来源:MarkerGlyphService.cs


示例5: PossibleTypeArgument

        private bool PossibleTypeArgument(ITextSnapshot snapshot, SyntaxToken token, CancellationToken cancellationToken)
        {
            var node = token.Parent as BinaryExpressionSyntax;

            // type argument can be easily ambiguous with normal < operations
            if (node == null || node.Kind() != SyntaxKind.LessThanExpression || node.OperatorToken != token)
            {
                return false;
            }

            // use binding to see whether it is actually generic type or method 
            var document = snapshot.GetOpenDocumentInCurrentContextWithChanges();
            if (document == null)
            {
                return false;
            }

            var model = document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken);

            // Analyze node on the left of < operator to verify if it is a generic type or method.
            var leftNode = node.Left;
            if (leftNode is ConditionalAccessExpressionSyntax)
            {
                // If node on the left is a conditional access expression, get the member binding expression 
                // from the innermost conditional access expression, which is the left of < operator. 
                // e.g: Case a?.b?.c< : we need to get the conditional access expression .b?.c and analyze its
                // member binding expression (the .c) to see if it is a generic type/method.
                // Case a?.b?.c.d< : we need to analyze .c.d
                // Case a?.M(x => x?.P)?.M2< : We need to analyze .M2
                leftNode = leftNode.GetInnerMostConditionalAccessExpression().WhenNotNull;
            }

            var info = model.GetSymbolInfo(leftNode, cancellationToken);
            return info.CandidateSymbols.Any(IsGenericTypeOrMethod);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:35,代码来源:LessAndGreaterThanCompletionSession.cs


示例6: FakeTextSnapshotLine

 public FakeTextSnapshotLine(ITextSnapshot snapshot, string text, int position, int lineNumber)
 {
     Snapshot = snapshot;
     this._text = text;
     LineNumber = lineNumber;
     Start = new SnapshotPoint(snapshot, position);
 }
开发者ID:kazu46,项目名称:VSColorOutput,代码行数:7,代码来源:FakeTextSnapshotLine.cs


示例7: InsertEmbedString

 private void InsertEmbedString(ITextSnapshot snapshot, string dataUri)
 {
     using (WebEssentialsPackage.UndoContext((DisplayText)))
     {
         _span.TextBuffer.Replace(_span.GetSpan(snapshot), dataUri);
     }
 }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:7,代码来源:EmbedSmartTagAction.cs


示例8: UDNParsingResults

        public UDNParsingResults(string path, ITextSnapshot snapshot, MarkdownPackage package, Markdown markdown, FolderDetails folderDetails)
        {
            var log = new OutputPaneLogger();
            ParsedSnapshot = snapshot;

            // Use the Publish Flag combo box to set the markdown details.
            markdown.PublishFlags.Clear();

            // Always include public
            markdown.PublishFlags.Add(Settings.Default.PublicAvailabilitiesString);

            foreach (var flagName in package.PublishFlags)
            {
                markdown.PublishFlags.Add(flagName);
            }

            Errors = new List<ErrorDetail>();
            Images = new List<ImageConversion>();
            Attachments = new List<AttachmentConversionDetail>();

            Document = markdown.ParseDocument(ParsedSnapshot.GetText(), Errors, Images, Attachments, folderDetails);

            DoxygenHelper.SetTrackedSymbols(Document.TransformationData.FoundDoxygenSymbols);

            CommonUnrealFunctions.CopyDocumentsImagesAndAttachments(
                path, log, folderDetails.AbsoluteHTMLPath, folderDetails.Language,
                folderDetails.CurrentFolderFromMarkdownAsTopLeaf, Images, Attachments);

            // Create common directories like css includes top level images etc. 
            // Needs to be created everytime the document is generated to allow
            // changes to these files to show in the preview window without
            // restarting VS.
            CommonUnrealFunctions.CreateCommonDirectories(
                folderDetails.AbsoluteHTMLPath, folderDetails.AbsoluteMarkdownPath, log);
        }
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:35,代码来源:UDNParsingResultsCache.cs


示例9: ProcessJsonObjectPropertyValues

 private void ProcessJsonObjectPropertyValues(JsonObjectNode rootNode, ITextSnapshot snapshot)
 {
     foreach (var jsonPropertyValuePair in rootNode.PropertyValues)
     {
         ProcessValue(snapshot, jsonPropertyValuePair.Value);
     }
 }
开发者ID:arelee,项目名称:ravendb,代码行数:7,代码来源:JsonOutliningSource.cs


示例10: GherkinTextBufferPartialParserListener

 public GherkinTextBufferPartialParserListener(GherkinDialect gherkinDialect, ITextSnapshot textSnapshot, GherkinFileEditorClassifications classifications, IGherkinFileScope previousScope, int changeLastLine, int changeLineDelta)
     : base(gherkinDialect, textSnapshot, classifications)
 {
     this.previousScope = previousScope;
     this.changeLastLine = changeLastLine;
     this.changeLineDelta = changeLineDelta;
 }
开发者ID:eddpeterson,项目名称:SpecFlow,代码行数:7,代码来源:GherkinTextBufferPartialParserListener.cs


示例11: GetGitDiffFor

        public IEnumerable<HunkRangeInfo> GetGitDiffFor(ITextDocument textDocument, ITextSnapshot snapshot)
        {
            string fileName = textDocument.FilePath;
            GitFileStatusTracker tracker = new GitFileStatusTracker(Path.GetDirectoryName(fileName));
            if (!tracker.IsGit)
                yield break;

            GitFileStatus status = tracker.GetFileStatus(fileName);
            if (status == GitFileStatus.New || status == GitFileStatus.Added)
                yield break;

            HistogramDiff diff = new HistogramDiff();
            diff.SetFallbackAlgorithm(null);
            string currentText = snapshot.GetText();

            byte[] preamble = textDocument.Encoding.GetPreamble();
            byte[] content = textDocument.Encoding.GetBytes(currentText);
            if (preamble.Length > 0)
            {
                byte[] completeContent = new byte[preamble.Length + content.Length];
                Buffer.BlockCopy(preamble, 0, completeContent, 0, preamble.Length);
                Buffer.BlockCopy(content, 0, completeContent, preamble.Length, content.Length);
                content = completeContent;
            }

            byte[] previousContent = null; //GetPreviousRevision(tracker, fileName);
            RawText b = new RawText(content);
            RawText a = new RawText(previousContent ?? new byte[0]);
            EditList edits = diff.Diff(RawTextComparator.DEFAULT, a, b);
            foreach (Edit edit in edits)
                yield return new HunkRangeInfo(snapshot, edit, a, b);
        }
开发者ID:Frrank1,项目名称:Git-Source-Control-Provider,代码行数:32,代码来源:GitCommands.cs


示例12: ParsingResult

 public ParsingResult(Settings settings,
     ITextSnapshot textSnapshot,
     IEnumerable<TextSpan> attributeSpans)
 {
     TextSnapshot = textSnapshot;
     AttributeSpans = attributeSpans.ToImmutableArray();
 }
开发者ID:t-denis,项目名称:DarkAttributes,代码行数:7,代码来源:ParsingResult.cs


示例13: Parse

		private static SyntaxConcept[] Parse(ITextSnapshot snapshot, out bool success)
		{
			var sb = new StringBuilder();
			sb.Append("format=json tokens=");
			var dsl = snapshot.GetText();
			sb.Append(Encoding.UTF8.GetByteCount(dsl));
			var either = Compiler.CompileDsl(sb, null, dsl, cms => (ParseResult)Serializer.ReadObject(cms));
			if (!either.Success)
			{
				success = false;
				Parsed(snapshot, new ParsedArgs(either.Error));
				return new SyntaxConcept[0];
			}
			var result = either.Value;
			if (result.Error != null)
			{
				var msg = (result.Error.Line >= 0 ? "Line: " + result.Error.Line + ". " : string.Empty) + result.Error.Error;
				Parsed(snapshot, new ParsedArgs(msg));
			}
			else Parsed(snapshot, new ParsedArgs());
			success = result.Error == null;
			if (result.Tokens == null)
				return EmptyResult;
			return result.Tokens.ToArray();
		}
开发者ID:instant-hrvoje,项目名称:dsl-compiler-client,代码行数:25,代码来源:SyntaxParser.cs


示例14: SemanticTaggerVisitor

 public SemanticTaggerVisitor(HlslClassificationService classificationService, ITextSnapshot snapshot, List<ITagSpan<IClassificationTag>> results, CancellationToken cancellationToken)
 {
     _classificationService = classificationService;
     _snapshot = snapshot;
     _results = results;
     _cancellationToken = cancellationToken;
 }
开发者ID:davidlee80,项目名称:HlslTools,代码行数:7,代码来源:SemanticTaggerVisitor.cs


示例15: CreateCompletionContext

        private ICompletionContext CreateCompletionContext(ISassStylesheet stylesheet, int position, ITextSnapshot snapshot)
        {
            ParseItem current = stylesheet as Stylesheet;

            if (position >= 0)
            {
                var previousCharacterIndex = FindPreceedingCharacter(position-1, snapshot);
                if (previousCharacterIndex != position)
                    current = stylesheet.Children.FindItemContainingPosition(previousCharacterIndex);

                current = current ?? stylesheet.Children.FindItemContainingPosition(position);
                if (current is TokenItem)
                    current = current.Parent;

                if (current != null && !IsUnclosed(current) && previousCharacterIndex != position)
                {
                    current = stylesheet.Children.FindItemContainingPosition(position);
                    if (current is TokenItem)
                        current = current.Parent;
                }
            }

            current = current ?? stylesheet as Stylesheet;

            return new CompletionContext
            {
                Document = Editor.Document,
                Current = current,
                //Predecessor = predecessor,
                Position = position,
                Cache = Cache,
                DocumentTextProvider = new SnapshotTextProvider(snapshot)
            };
        }
开发者ID:profet23,项目名称:SassyStudio,代码行数:34,代码来源:SassCompletionSource.cs


示例16: CreateText

            private static SnapshotSourceText CreateText(ITextSnapshot editorSnapshot)
            {
                var strongBox = s_textBufferLatestSnapshotMap.GetOrCreateValue(editorSnapshot.TextBuffer);
                var text = strongBox.Value;
                if (text != null && text._reiteratedVersion == editorSnapshot.Version.ReiteratedVersionNumber)
                {
                    if (text.Length == editorSnapshot.Length)
                    {
                        return text;
                    }
                    else
                    {
                        // In editors with non-compliant Undo/Redo implementations, you can end up
                        // with two Versions with the same ReiteratedVersionNumber but with very
                        // different text. We've never provably seen this problem occur in Visual 
                        // Studio, but we have seen crashes that look like they could have been
                        // caused by incorrect results being returned from this cache. 
                        try
                        {
                            throw new InvalidOperationException(
                                $"The matching cached SnapshotSourceText with <Reiterated Version, Length> = <{text._reiteratedVersion}, {text.Length}> " +
                                $"does not match the given editorSnapshot with <{editorSnapshot.Version.ReiteratedVersionNumber}, {editorSnapshot.Length}>");
                        }
                        catch (Exception e) when (FatalError.ReportWithoutCrash(e))
                        {
                        }
                    }
                }

                text = new SnapshotSourceText(editorSnapshot, editorSnapshot.TextBuffer.GetEncodingOrUTF8());
                strongBox.Value = text;
                return text;
            }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:33,代码来源:Extensions.SnapshotSourceText.cs


示例17: CalculateDeletionStartFromStartPosition

        private static int CalculateDeletionStartFromStartPosition(ITextSnapshot snapshot, int startPosition)
        {
            var position = startPosition - 1;

            if (position < 0)
            {
                return 0;
            }

            while (true)
            {
                if (position > 0)
                {
                    var ss = new SnapshotSpan(snapshot, position, 1);
                    var text = ss.GetText();

                    if (text != null && !"\r\n".Contains(text) && string.IsNullOrWhiteSpace(text))
                    {
                        --position;
                        continue;
                    }

                    ++position;
                }

                return position;
            }
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:28,代码来源:RemoveCssRuleSmartTagAction.cs


示例18: GetCaretPositionInSubjectBuffer

        public SnapshotPoint GetCaretPositionInSubjectBuffer(SnapshotPoint viewCaretPosition, ITextSnapshot bufferSnapshot)
        {
            var currentModelSpanInView = GetCurrentSpanInView(viewCaretPosition.Snapshot);
            SnapshotSpan currentModelSpanInSubjectBuffer = GetCurrentSpanInSubjectBuffer(bufferSnapshot);

            return currentModelSpanInSubjectBuffer.Start + (viewCaretPosition - currentModelSpanInView.Start);
        }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:7,代码来源:Model.cs


示例19: GetPoint

 public SnapshotPoint? GetPoint(ITextSnapshot targetSnapshot, PositionAffinity affinity) {
     try {
         return _trackingPoint.GetPoint(targetSnapshot);
     } catch (ArgumentException) {
         return null;
     }
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:7,代码来源:MockMappingPoint.cs


示例20: ConstructAsync

        /// <summary>
        /// Asynchronously constructs a line map from a <paramref name="snapshot"/> and <paramref name="code"/>.
        /// </summary>
        /// <param name="snapshot">The current text snapshot.</param>
        /// <param name="code">The code to derive a line map from.</param>
        /// <param name="cancelToken">Cancellation token.</param>
        /// <returns>
        /// A <see cref="LineMap"/> if <paramref name="code"/> was parsed correctly,
        /// <c>null</c> if there was invalid code or it was canceled.
        /// </returns>
        internal static Task<LineMap> ConstructAsync(ITextSnapshot snapshot, string code, CancellationToken cancelToken)
        {
            if (snapshot == null)
                throw new ArgumentNullException ("snapshot");
            if (code == null)
                throw new ArgumentNullException ("code");

            return Task<LineMap>.Factory.StartNew (() =>
            {
                try
                {
                    var tree = SyntaxTree.Parse (code, cancellationToken: cancelToken);
                    if (tree.Errors.Any (p => p.ErrorType == ErrorType.Error))
                        return null;

                    var identifier = new IdentifyingVisitor();
                    tree.AcceptVisitor (identifier);

                    var spans = new Dictionary<int, ITrackingSpan> (identifier.LineMap.Count);
                    foreach (var kvp in identifier.LineMap)
                    {
                        ITextSnapshotLine line = snapshot.GetLineFromLineNumber (kvp.Value - 1);
                        ITrackingSpan span = snapshot.CreateTrackingSpan (line.Extent, SpanTrackingMode.EdgeExclusive);
                        spans.Add (kvp.Key, span);
                    }

                    return (cancelToken.IsCancellationRequested) ? null : new LineMap (spans);
                }
                catch (OperationCanceledException)
                {
                    return null;
                }
            }, cancelToken);
        }
开发者ID:ermau,项目名称:Instant,代码行数:44,代码来源:LineMap.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITextSnapshotLine类代码示例发布时间:2022-05-24
下一篇:
C# ITextRunConstructionContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap