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


C# ITextSnapshot.GetText方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: Parse

 internal void Parse(ITextSnapshot snapshot, out LanguageService.SyntaxTree.ITokenStream TokenStream, string path)
 {
     string source = snapshot.GetText();
     // Currently we "eat" all Exception that might be raised
     // by XSharpSyntaxTree.ParseText
     TokenStream = null;
     try
     {
         LanguageService.CodeAnalysis.SyntaxTree tree = XSharpSyntaxTree.ParseText(source, null, path);
         var syntaxRoot = tree.GetRoot();
         // Get the antlr4 parse tree root
         var xtree = ((LanguageService.CodeAnalysis.XSharp.Syntax.CompilationUnitSyntax)syntaxRoot).XSource;
         TokenStream = ((LanguageService.CodeAnalysis.XSharp.Syntax.CompilationUnitSyntax)syntaxRoot).XTokenStream;
         //
         var walker = new LanguageService.SyntaxTree.Tree.ParseTreeWalker();
         var discover = new XSharpTreeDiscover();
         discover.Snapshot = snapshot;
         discover.xsharpBraceCloseType = xsharpBraceCloseType;
         discover.xsharpBraceOpenType = xsharpBraceOpenType;
         discover.xsharpIdentifierType = xsharpIdentifierType;
         discover.xsharpRegionStartType = xsharpRegionStartType;
         discover.xsharpRegionStopType = xsharpRegionStopType;
         // Walk the tree. The TreeDiscover class will collect the tags.
         walker.Walk(discover, xtree);
         this.tags = discover.tags;
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e.Message);
     }
 }
开发者ID:X-Sharp,项目名称:XSharpPublic,代码行数:31,代码来源:XSharpTagger.cs

示例7: LinePreservingCodeReplacer

 private LinePreservingCodeReplacer(ITextView view, string newCode, Span range) {
     _view = view;
     _snapshot = view.TextBuffer.CurrentSnapshot;
     _oldCode = _snapshot.GetText(range);
     _newCode = newCode;
     _newLines = newCode.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
     _startingReplacementLine = _snapshot.GetLineFromPosition(range.Start).LineNumber;
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:8,代码来源:LinePreservingCodeReplacer.cs

示例8: SnapshotCharStream

 public SnapshotCharStream(ITextSnapshot snapshot, Span cachedSpan)
 {
     //System.Diagnostics.Contracts.Contract.Requires<ArgumentNullException>(snapshot != null, "snapshot");
     this.Snapshot = snapshot;
     this._explicitCache = true;
     this._currentSnapshotLineStartIndex = cachedSpan.Start;
     this._currentSnapshotLine = snapshot.GetText(cachedSpan);
 }
开发者ID:smartmobili,项目名称:parsing,代码行数:8,代码来源:SnapshotCharStream.cs

示例9: ParseSnapshot

 public List<Feature> ParseSnapshot(ITextSnapshot textSnapshot)
 {
     var text = textSnapshot.GetText();
     var tempFile = text.ToTempFile();
     var config = NBehaveConfiguration.New.SetScenarioFiles(new[] {tempFile});
     var scenarioParser = new ParseScenarioFiles(config);
     var features = scenarioParser.LoadFiles(config.ScenarioFiles).ToList();
     return features;
 }
开发者ID:AngelPortal,项目名称:NBehave,代码行数:9,代码来源:GherkinFileEditorParser.cs

示例10: ClassifyArguments

 public IEnumerable<ClassificationSpan> ClassifyArguments(ITextSnapshot snapshot, Span argumentsSpan, Span spanToClassify)
 {
     string arguments = snapshot.GetText(argumentsSpan);
     int argumentsStart = argumentsSpan.Start;
     foreach (var pos in GetNoConfigPositions(arguments))
     {
         var snapshotSpan = new SnapshotSpan(snapshot, new Span(argumentsStart + pos, s_noConfigParameterNameLength));
         yield return new ClassificationSpan(snapshotSpan, _registry.Keyword);
     }
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:10,代码来源:CSharpVBResetCommand.cs

示例11: ClassifyArguments

        public override IEnumerable<ClassificationSpan> ClassifyArguments(ITextSnapshot snapshot, Span argumentsSpan, Span spanToClassify)
        {
            string arguments = snapshot.GetText(argumentsSpan);

            int noConfigStart, noConfigEnd;
            bool? init = ParseArguments(arguments, out noConfigStart, out noConfigEnd);

            if (noConfigStart >= 0)
            {
                yield return new ClassificationSpan(new SnapshotSpan(snapshot, Span.FromBounds(argumentsSpan.Start + noConfigStart, argumentsSpan.Start + noConfigEnd)), _registry.Keyword);
            }
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:12,代码来源:ResetCommand.cs

示例12: GetSemanticModel

        private SemanticModel GetSemanticModel(ITextBuffer buffer)
        {
            if (currentSnapshot == buffer.CurrentSnapshot)
                return semanticModelCache;

            currentSnapshot = buffer.CurrentSnapshot;
            semanticModelCache = new SemanticModel(shadowClass);

            var code = currentSnapshot.GetText();

            codeLexer.Tokenize(semanticModelCache, code);
            templateLexer.Tokenize(semanticModelCache, code);
            
            return semanticModelCache;
        }
开发者ID:ChinaJason,项目名称:Typewriter,代码行数:15,代码来源:Editor.cs

示例13: ParseTextSnapshot

        private void ParseTextSnapshot(ITextSnapshot snapshot)
        {
            var scanner = new TemplateScanner(snapshot.GetText());

            var parser = new TemplateParser(scanner);
            parser.Parse();

            // Always return a template object, even if the parser couldn't build one, to avoid downstream errors.
            Template template = parser.Template ?? new Template();

            var errors = new List<TemplateError>(parser.Errors);
            errors.AddRange(template.Validate());

            this.OnTemplateChanged(new TemplateAnalysis(snapshot, template, errors));
        }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:15,代码来源:TemplateAnalyzer.cs

示例14: Get

        internal SourceText Get(ITextSnapshot textSnapshot)
        {
            Requires.NotNull(textSnapshot, nameof(textSnapshot));

            SourceText sourceText = null;
            if (this.sources.TryGetValue(textSnapshot, out sourceText))
            {
                return sourceText;
            }

            sourceText = new SourceText(textSnapshot.GetText());
            this.sources.Add(textSnapshot, sourceText);

            return sourceText;
        }
开发者ID:Strongc,项目名称:VSLua,代码行数:15,代码来源:SourceTextCache.cs

示例15: GenerateContent

        public virtual string GenerateContent(ITextSnapshot snapshot, IEnumerable<ITextRange> languageBlocks, out ProjectionMapping[] mappings) {
            var mappingsList = new List<ProjectionMapping>();
            var secondaryIndex = 0;

            var sb = new StringBuilder();

            foreach (var b in languageBlocks) {
                var text = snapshot.GetText(b.Start, b.Length);
                secondaryIndex = sb.Length;

                sb.AppendLine(text);
                var m = new ProjectionMapping(b.Start, secondaryIndex, b.Length);
                mappingsList.Add(m);
            }

            mappings = mappingsList.ToArray();
            return sb.ToString();
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:18,代码来源:BufferGenerator.cs


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