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


C# ITextSnapshot类代码示例

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


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


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